View Full Version : Code to change usergroup at registration
kirstyd
10-29-2008, 03:29 PM
I'm wanting to put users who meet certain conditions when they register into the moderated user group so we can check them before letting them in. I've added a plugin at the register_addmember_complete hook which identifies the prospective users just fine, but I can't figure out the right bit of code to get them put into the moderated user group (which is group id 4).
I'm trying: $userdata->user[usergroupid]=4; but it's having no effect.
Can anyone help me out with the correct line of code please?
thanks
kirsty
Jinovich
10-29-2008, 05:22 PM
Easiest way to do this would be to go to vbulletin options --> User registration -> moderate new users.
This way it will add users in to "Coppa users awaiting moderation" usergroup.
Whatever your trying to achieve I am certain you could do without plugins or hacks.
kirstyd
10-29-2008, 07:06 PM
That would put all my new users into moderation though, there are only a handful of rogues I want to catch with this.
thanks
kirsty
Lynne
10-29-2008, 07:19 PM
I've never really played with the registration process, but looking at the code, I'm wondering if you are picking a hook location that is after the userdata save process. Have you tried using the hook "register_addmember_process"? It looks like the save occurs after that one but before the one you picked. In fact, look at line 359, that is where the usergroupid is set. You may just need to just make a userdate->set call like that one at the hook location I suggested.
noppid
10-29-2008, 07:26 PM
$userdata->set('usergroupid', 4); on hook register_addmember_process
Of course wrap it in your conditions.
Marco van Herwaarden
10-30-2008, 08:19 AM
What is your condition to place the new user in 1 or the other usergroup?
kirstyd
10-30-2008, 09:45 AM
$userdata->set('usergroupid', 4); on hook register_addmember_process
Of course wrap it in your conditions.
Fabulous! That's just what I needed. Thanks to everyone for their help.
What is your condition to place the new user in 1 or the other usergroup?
At the moment I'm just trapping persistently annoying but not very cunning trolls by their IP address range ($userdata->user[ipaddress]). I don't want to ban them outright because I'm likely to pick up non-troll users using the same IP address range, I just want an easy way of knowing they are about so the moderators can monitor them.
thanks
kirsty
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.