Quote:
Originally Posted by adamdavidconn
hi.
I am wondering, how can you make a user be changed to a different usergroup, or added to a secondry one after completion and submission of the form.
many thanks
adam
|
This code worked with vB v3.x it should work with vB v4.x
but I haven't tested it with vb v4.x.
Form Hook: Before Submit
PHP Code:
PHP Code:
if ($complete)
{
$userinfo = $vbulletin->userinfo;
$user['usergroupid'] = 4;
if (empty($user['usergroupid']))
{
$user['usergroupid'] = 2;
}
$getusergroupid = iif($userinfo['displaygroupid'] != $userinfo['usergroupid'], $userinfo['displaygroupid'], $user['usergroupid']);
$user_usergroup =& $vbulletin->usergroupcache["$user[usergroupid]"];
$display_usergroup =& $vbulletin->usergroupcache["$getusergroupid"];
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$userdata->set_existing($userinfo);
$userdata->set('usergroupid', $user['usergroupid']);
$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
);
require_once(DIR . '/includes/functions_ranks.php');
if ($user['userid'] == $vbulletin->userinfo['userid'])
{
$vbulletin->userinfo['usergroupid'] = $user['usergroupid'];
$vbulletin->userinfo['displaygroupid'] = $user['usergroupid'];
}
$userdata->save();
}