Quote:
Originally Posted by Sarcoth
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!
|
Woops it shouldn't have removed all other membergroups, there was a little mistake in the code

. But if thats what you wanted then that alright
PHP Code:
if ($complete)
{
$user = $userinfo = $vbulletin->userinfo;
$newmembergroupid = '18';
$display_usergroup = $user['membergroupids'] = $newmembergroupid;
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$userdata->set_existing($userinfo);
$userdata->set('membergroupids', $user['membergroupids']);
$userdata->set_usertitle(
$user['customtitle'] ? $user['usertitle'] : '',
false,
$display_usergroup,
($user_usergroup['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canusecustomtitle']) ? true : false,
($user_usergroup['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cancontrolpanel']) ? true : false
);
$vbulletin->userinfo['membergroupids'] = $user['membergroupids'];
$vbulletin->userinfo['displaygroupid'] = $newmembergroupid;
$userdata->save();
}