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

#3
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 :) */ 
Do not let your difficulties fill you with anxiety, after all it is only in the darkest nights that stars shine more brightly. - Ali(a.s)

Developer( PHP, Python, C++, HTML+CSS, JS I am available for Hire. Message Me for details.


Users browsing this thread: 1 Guest(s)