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 yet
foreach( $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 :) */
Thanks for this :noh:
I wanna add this to "already-made" plugins, so:
Where would you insert that code at?