Quote:
Originally Posted by adamdavidconn
ok, thanks. So I guess the code I need to edit is
PHP Code:
if ($complete) { $userinfo = $vbulletin->userinfo; $user['usergroupid'] = 4; if (empty($user['usergroupid'])) { $user['usergroupid'] = 2; }
Could you explain how I would configure this. The numbers at the end reference the usergroup id, but what do the 2 variables corrolate to?
EDIT: I worked out that
PHP Code:
$user['usergroupid'] = 4;
moves a user to a new usergroup. However, I am unsure how to add a additional usergroup, and not make them change their primary
|
Yes that would only change the primary usergroup, use the following code to add a secondary usergroup.
You will need to change $a_userid to the desired userid of the user you want to change the usergroup of.
Also you will need to change the two occurances of 4 to the desired additional usergroup's usergroupid.
Form Hook: Before Submit
PHP Code:
if ($complete)
{
/*alter this userid*/
$a_userid = 2;
$userinfo = fetch_userinfo($a_userid);
if (empty($user['membergroupids']))
{
/*alter this number below*/
$user['membergroupids'] = '4';
} else {
/*alter this number below, but leave the comma*/
$user['membergroupids'] .= ',4';
}
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$userdata->set_existing($userinfo);
$userdata->set('membergroupids', $user['membergroupids']);
$userdata->save();
}