Quote:
Originally Posted by bananalive
Use this:
Form Hook: Before Submit
PHP Code:
if ($complete)
{
$userinfo = $vbulletin->userinfo;
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']);
$vbulletin->userinfo['membergroupids'] = $user['membergroupids'];
$userdata->save();
}
|
Very nice. I got this working without any problems. I notice that it removes the userid from all membergroups and then just adds them to the one. If I know the membergroup id, can I remove them from just one and add them to the other. For example, when they submit this form, I'd like to remove them from 17 and add them to 18.
Also, is there a way for me to update their "Display Usergroup" to the usergroup (18) they are added to? I've done coding with membergroups before, but I've never seen anything update the display part.
Fun stuff, thanks!