MyBB Support

[Plugin Help] Making available to certain usergroups

Submitted by Tropical, , Thread ID: 3944

Thread Closed

RE: [Plugin Help] Making available to certain usergroups

OP
This post was last modified: 18-05-2015, 09:45 AM by Tropical
#4
18-05-2015, 09:36 AM
Sozin 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,); //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?

Users browsing this thread: 1 Guest(s)