View Full Version : change user permission
ahmedHasan
12-19-2011, 11:35 AM
Hello all,
I'm new in vBulletin programming.
I want to change user permssions to access certain forums in my vBulletin via PHP script. I can accept if i can create new user group or even update the permission for each user (Edit Access mask)
I've read the manual, searched on the forum for help but i don't find any thing.
Can someone helps me how to do that (if possible)?
Thanks
Ahmed
Here's a short test script that adds a secondary usergroup to a user:
require_once('./global.php');
// init data manager
$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_CP);
$userid = 6;
$addgroupid = 9;
$userinfo = fetch_userinfo($userid);
if (!$userinfo)
{
print_stop_message('invalid_user_specified');
}
$userdata->set_existing($userinfo);
$secondary_groups = fetch_membergroupids_array($userinfo, false);
if (!in_array($addgroupid, $secondary_groups))
{
$secondary_groups[] = $addgroupid;
$userdata->set('membergroupids', $secondary_groups);
$userdata->save();
}
echo "OK";
So you could create a user group that adds he necessary permission, then use something like this to add that group to a user as a secondary group.
ahmedHasan
12-22-2011, 12:31 PM
Thank you Kh99 for your reply
But, What i really want is some code (if possible) to create a user group.
Best regards
Ahmed
ahmedHasan
01-12-2012, 09:39 AM
Can someone help me, or confirm that this is not possible with vBulletin current APIs?
Thnaks in advance
It can be done - it's done in admincp/usergroup.php, in the section that starts with
// ###################### Start insert / update #######################
if ($_POST['do'] == 'update')
{
That code uses the values submitted from the adminCP usergroup form so you'd have to adapt it. For instance, some of the values are expected to be in $vbulletin->GPC['usergroup'], so you can easily replace that with your own array.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.