snotek
Make the following changes to your vbulletinCMS file (whichever one you are using).
Find;
PHP Code:
$this->getUserStmt = new Statement("SELECT userid AS id, username AS login, usergroupid FROM {$GLOBALS['tableprefix']}user WHERE userid=?");
Replace with;
PHP Code:
$this->getUserStmt = new Statement("SELECT userid AS id, username AS login, usergroupid, membergroupids FROM {$GLOBALS['tableprefix']}user WHERE userid=?");
Find;
PHP Code:
$rec['roles'] = $this->getRoles($rec['usergroupid']);
Replace with;
PHP Code:
$rec['usergroupid'] .= ",".$rec['membergroupids'] ; //added by Paul M
$rec['roles'] = $this->getRoles($rec['usergroupid']);
Find the getRoles function ;
PHP Code:
function getRoles($usergroupid) {
< # current block of code # >
}
Replace it with a new version ;
PHP Code:
// Paul M Version - Edit to set user roles for different vB usergroups
function getRoles($usergroupid) {
// Set default access
$userrole = ROLE_NOBODY ;
$groups = explode(',',$usergroupid);
// Set Allowed groups
if (in_array(2,$groups)) $userrole = ROLE_USER;
if (in_array(7,$groups)) $userrole = ROLE_USER;
//Set Staff groups
if (in_array(5,$groups)) $userrole = ROLE_ADMIN;
if (in_array(6,$groups)) $userrole = ROLE_ADMIN;
//Set Banned groups
if (in_array(8,$groups)) $userrole = ROLE_NOBODY;
if (in_array(9,$groups)) $userrole = ROLE_NOBODY;
return $userrole;
}
Edit the above function for your usergroups. This is working fine on my test system.
This version assigns access in the following priority based on both primary and secondary groups.
1. Assign default access (which is set to NO access).
2. If they are a member of an allowed group, grant USER access.
3. If they are a member of a staff group, grant ADMIN access.
4. If they are a member of a banned group, grant NO access.