public function getLoginRedirect($provider = null)
{
if (($provider !== null && $provider->initialRegistration) && JFBCFactory::config()->getSetting('facebook_new_user_redirect') != '')
{
$itemId = JFBCFactory::config()->getSetting('facebook_new_user_redirect', '0');
$redirect = SCSocialUtilities::getLinkFromMenuItem($itemId, false);
}
else if (JFBCFactory::config()->getSetting('facebook_login_redirect') != '')
{
$itemId = JFBCFactory::config()->getSetting('facebook_login_redirect', '0');
$redirect = SCSocialUtilities::getLinkFromMenuItem($itemId, false);
}
else
{
// Get whatever has been saved in the com_jfbconnect.login.redirect state variable.
$redirect = JFactory::getApplication()->getUserState('com_jfbconnect.login.return', 'index.php');
//JFactory::getApplication()->setUserState('com_jfbconnect.login.return', null);
}
return $redirect;
}
else
{
// Get whatever has been saved in the com_jfbconnect.login.redirect state variable.
$redirect = JFactory::getApplication()->getUserState('com_jfbconnect.login.return', 'index.php');
//JFactory::getApplication()->setUserState('com_jfbconnect.login.return', null);
$user = JFactory::getUser();
$groups = $user->get('groups');
$authGroups = $user->getAuthorisedGroups();
if (in_array(4, $authGroups))
$redirect = 'index.php?test=blah';
else if (in_array(5, $authGroups))
$redirect = 'index.php?test=boo';
}
The plugin I linked to above is to let a user select their group on registration. If you're looking to assign them to a group after they register, or even create their account beforehand and assign them to a group, you wouldn't want to use that plugin as it wouldn't be necessary.What I want to be able to do is assign users to one of the groups (which I know how to do),
alzander wrote:
That last part with the if (in_array(..)) statements is where you can check for a certain user group ID and redirect based on that. If no group is matched, then the user will be left on the same page. Oh yeah, you'll need the redirection setting in JFBConnet to be set to "Same Page" for that to work.else { // Get whatever has been saved in the com_jfbconnect.login.redirect state variable. $redirect = JFactory::getApplication()->getUserState('com_jfbconnect.login.return', 'index.php'); //JFactory::getApplication()->setUserState('com_jfbconnect.login.return', null); $user = JFactory::getUser(); $groups = $user->get('groups'); $authGroups = $user->getAuthorisedGroups(); if (in_array(4, $authGroups)) $redirect = 'index.php?test=blah'; else if (in_array(5, $authGroups)) $redirect = 'index.php?test=boo'; }
Whew! I hope that gets you going, but please let me know any feedback or comments you have.
Thanks,
Alex
(in_array(4, $authGroups))
Woops, guess I could have explained that more... To determine the number to use there, in the admin area, simply go to Users -> Groups. Then, note the "ID" column in the right. The ID there is what you need to use. For example, if the Teachers row has an ID of 12, use 12 in the in_array(12, $authGroups)) line and the $redirect variable right after that line will be used for Teachers.How do I determine what is in the In_array(4, $authGroups)) ?
Join our newsletter to get alerts for Joomla releases, tips and tricks and extension updates.