razec
01-22-2010, 04:13 AM
I'm just curious as to what the best practice is for changing a user's primary usergroup through code. I tried searching the vB4 forum here for information on it but I didn't find anything. Is there a function that handles it, or a guide that I can reference with more information?
Can I just do it with something like this? Mind you this could be completely off which is why I haven't even tried it yet.
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$vbulletin->userinfo['usergroupid'] = $new_group = $userdata->save();
This is based on observations I made in register.php. I'm pretty sure it's not correct because I'm probably interpreting what's going on wrong. The point of this change is to allow the user to set what type of user they are, and in doing so this will change their primary group to match their selection. This takes place after the registration is complete, but I referred to register.php because I knew that's a place where the user's group (and other information) would be set/changed in code.
Can I just do it with something like this? Mind you this could be completely off which is why I haven't even tried it yet.
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$vbulletin->userinfo['usergroupid'] = $new_group = $userdata->save();
This is based on observations I made in register.php. I'm pretty sure it's not correct because I'm probably interpreting what's going on wrong. The point of this change is to allow the user to set what type of user they are, and in doing so this will change their primary group to match their selection. This takes place after the registration is complete, but I referred to register.php because I knew that's a place where the user's group (and other information) would be set/changed in code.