PDA

View Full Version : moving people to usergroups automatically


wtrk
11-07-2010, 05:40 PM
im using vb 3.-latest and i have a question about moving users to a usergroup based on profile filed answers. in previous version of vbulletin i swear this worked as a plugin with a hook of register_activate_process:


// Get the value for field
$user = $db->query_first("
SELECT field7
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");

// change user groups

if ($user['field7'] == 'yes')
{
$userdata->set('usergroupid', 23);
}
if ($user['field7'] == 'no')
{
$userdata->set('usergroupid', 24);

}


can somebody help me get this to work?

Lynne
11-07-2010, 05:49 PM
Are you moderating users? If so, that isn't going to work.

wtrk
11-07-2010, 06:31 PM
no not moderating users.

kh99
11-07-2010, 08:13 PM
I don't understand all the details of the registration process, but looking at register.php where that hook is called it looks like there's code above that that uses the group id, so I think your code might need to repeat some of that.

Lynne
11-07-2010, 08:14 PM
So they sign up and immediately become a registered user (except you want them to go to another usergroup)? (Isn't there a mod that does this?)

kh99
11-07-2010, 08:20 PM
I haven't tried this at all, but if I had to guess I'd say your code should be something like:


// Get the value for field
$user = $db->query_first("
SELECT field7
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");

// change user groups

if ($user['field7'] == 'yes')
$newgroup = 23;
else
$newgroup = 24;

$getusergroupid = iif($userinfo['displaygroupid'] != $userinfo['usergroupid'], $userinfo['displaygroupid'], $newgroup);

$user_usergroup =& $vbulletin->usergroupcache["$newgroup"];
$display_usergroup =& $vbulletin->usergroupcache["$getusergroupid"];
$userdata->set('usergroupid', $newgroup);
$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
);

if ($user['userid'] == $vbulletin->userinfo['userid'])
{
$vbulletin->userinfo['usergroupid'] = $newgroup;
$vbulletin->userinfo['displaygroupid'] = $newgroup;
}


ETA: (oops - posted this before I read Lynne's. Maybe there is an existing mod).

FreshFroot
11-09-2010, 03:37 PM
wait..? can't you use the promotion method. Where you can set X posts, date...etc..etc.. to push a user into a certain usergroup?

wtrk
11-09-2010, 04:51 PM
wait..? can't you use the promotion method. Where you can set X posts, date...etc..etc.. to push a user into a certain usergroup?

So they sign up and immediately become a registered user (except you want them to go to another usergroup)? (Isn't there a mod that does this?)

I looked high and low for a mod that does this. I originally think I got that code or the idea for that from a post somewhere here on vborg (but I cant find it, the search sucks here).

I dont want to promote the user based on post, date, etc. but by profile field.

FreshFroot
11-09-2010, 09:21 PM
I looked high and low for a mod that does this. I originally think I got that code or the idea for that from a post somewhere here on vborg (but I cant find it, the search sucks here).

I dont want to promote the user based on post, date, etc. but by profile field.
hmm the easy way would be to use the promotion system, but modify it to work for profile fields. The problem would be if the fields are editable or not? If they are say a selection of options, then it's easy to do.

If they can type anything in then it's going to be a tough one.

wtrk
11-10-2010, 03:03 PM
Im trying to make it as simple as possible by just using single-selection radio buttons and only giving a 'yes' or 'no' option. im not a programmer, ive got pretty basic php/mysql skills.

update: there is a plugin to move users on registration, but none to move users on profile update.

makaiguy
04-08-2013, 07:24 PM
update: there is a plugin to move users on registration, but none to move users on profile update.
Interestingly, that's exactly what I'm looking for at the moment. Can somebody point me to it? vB 3.8.7 PL3