PDA

View Full Version : Programmatically adding a secondary usergroup to a user


redraider
03-25-2011, 05:29 PM
I am using google checkout outside the vbulletin system. After user pays, I want to add him to the "paid members" usergroup (as a secondary usergroup) to vBulletin. How can I achieve this programatically? As a result of this addition the customer would have some additional access as per the "paid members" permissions.

Please guide.

Yellow Slider
03-27-2011, 07:07 PM
You can do something like this:

$paid_members_ugid = 10;
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
$userdm->set_existing($userinfo);
$userdata->set('membergroupids', ($userinfo['membergroupids'] ? implode(", ", array_push(explode(", ", $userinfo['membergroupids']), $paid_members_ugid)) : $paid_members_ugid));
$userdm->save;
Haven't tested it, but it's supposed to work.