Restrict page to usergroups

Discussion in 'MyBB Discussions' started by tech, Jan 8, 2010.

  1. tech

    tech Regular Member

    Joined:
    Jun 13, 2009
    Messages:
    490
    Likes Received:
    11
    I've got a custom page on Mybb from this Tut: Include your custom pages in Mybb

    Like vB you can restrict a page to certain usergroups but whats the code for MyBB?

    I've searched Google and Mybboard, I posted here because there wasn't really anywhere on the MyBB forums to post.

    Thanks
     
  2. Ryan Ashbrook

    Ryan Ashbrook Regular Member

    Joined:
    Jun 29, 2009
    Messages:
    343
    Likes Received:
    25
    Location:
    Cincinnati, Ohio
    Try:

    PHP:
    if ( $mybb->user['usergroup'] == 'usergroup id here' )
    {
    // code here
    }
    else
    {
    die ( 
    'You can\'t access this page!' );
    }
     
    2 people like this.
  3. tech

    tech Regular Member

    Joined:
    Jun 13, 2009
    Messages:
    490
    Likes Received:
    11
    Works, Would you know how to do it for 2 Usergroups? The ID's are 4 and 8, Ive tried putting the code twice (if ( $mybb->user['usergroup'] == 'usergroup id here' ) ), using commas and '4', '8' but nothing seems to work.
     
  4. Ryan Ashbrook

    Ryan Ashbrook Regular Member

    Joined:
    Jun 29, 2009
    Messages:
    343
    Likes Received:
    25
    Location:
    Cincinnati, Ohio
    PHP:
    $allowedgroups = array ( '4''8' );
    if ( 
    in_array $mybb->user['usergroup'], $allowedgroups )
    {
    // code here
    }
    else
    {
    die ( 
    'Uh oh, accessing stuff you\'re not supposed too. ;)' );
    }
     

Share This Page