18-05-2015, 09:36 AMSozin Wrote: Algorithm: 1. Get users current groups 2. Check if user's group is in allowed usergroups PHP Code:$groups = array_merge( (array)$GLOBALS['mybb']->user['usergroup'], (array)$GLOBALS['mybb']->user['displaygroup'], explode( ',', $GLOBALS['mybb']->user['additionalgroups'] ) );$allowedgroups = array( 1,2 ); //Gids of allowed groups$allowed = FALSE; //Not Allowed yetforeach( $allowedgroups AS $group ){ if( in_array( $group, $allowedgroups ) ) { $allowed = TRUE; break; } }if( $allowed === FALSE ){ error( 'You are not allowed to access this plugin/page.' );}/* Here you can leave the rest of your code :) */
$groups = array_merge( (array)$GLOBALS['mybb']->user['usergroup'], (array)$GLOBALS['mybb']->user['displaygroup'], explode( ',', $GLOBALS['mybb']->user['additionalgroups'] ) );$allowedgroups = array( 1,2 ); //Gids of allowed groups$allowed = FALSE; //Not Allowed yetforeach( $allowedgroups AS $group ){ if( in_array( $group, $allowedgroups ) ) { $allowed = TRUE; break; } }if( $allowed === FALSE ){ error( 'You are not allowed to access this plugin/page.' );}/* Here you can leave the rest of your code :) */
Loading Info...