The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Change primary usergroup via PHP
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. Code:
$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. |
#2
|
|||
|
|||
PHP Code:
|
#3
|
|||
|
|||
I get an error when this code runs:
Quote:
Code:
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY); $userdata->set('usergroupid', $new_group); $userdata->save(); |
#4
|
||||
|
||||
You should have something like this before calling set,
PHP Code:
|
#5
|
|||
|
|||
Ahh, got it. That did the trick! Thank you.
|
#6
|
|||
|
|||
huge thank you for this thread (idk why im not able to thank the posts directly).
i was looking for this for years. using it for the "delete my account" issues, switching them to another usergroup that hides them from members list and locks them out of forums, giving error message that they have deactivated their account, but can reactivate if they changed their mind. thank you. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|