Topic-icon Assign user groups automatically

Active Subscriptions:

None
12 years 8 months ago #36979 by bottleCONTENT
Is it possible to assign user groups when the registration flow is set to Automatic?

Regards,
Pedja
The topic has been locked.
Support Specialist
12 years 8 months ago #36999 by alzander
Pedja,
We have a plugin that can let the user select a group during registration when using the "Normal" mode. Right now, the plugin doesn't support the automatic registration mode. We're planning to release the final version that supports both modes with the v5.2 release in late October.

If you need a solution before then, there's a few lines of code we could help you implement what you're looking for with the current release as well.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 8 months ago #37015 by bottleCONTENT
It would be nice if we could have that solution before the end of October.
Is it OK to set it in Login.php after the following:

// Check if no mapping, and Automatic Registration is set. If so, create the new user.
if (!$jUserId && !JFBCFactory::config()->getSetting('create_new_users'))
{ # User is not in system, should create their account automatically
if ($loginRegisterModel->autoCreateUser($providerUserId, $provider))
$jUserId = $userMapModel->getJoomlaUserId($providerUserId, $provider->name);
}
The topic has been locked.
Support Specialist
12 years 8 months ago #37028 by alzander
The code you're looking for would actually be in the /components/com_jfbconnect/models/loginregister.php file. Around line 295, you'll see:
$defaultUserGroup = $config->get('new_usertype', 2);
        $instance->set('usertype', 'deprecated');
        $instance->set('groups', array($defaultUserGroup));
You'd want to update that last line with whatever group the user should be in. You can find the group IDs in the User Manager of Joomla. Use the IDs there in that last line. So, if the user should be in group 5 and 10, you'd update it like:
$instance->set('groups', array('5', '10'));
Test that and let me know how it goes.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 8 months ago #37059 by bottleCONTENT
It works!!!

Thanks Alex.
The topic has been locked.