MyBB Community Forums

Full Version: Protect Custom Pages Depending on User Group
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I was wondering what code I must add to templates to hide pages to people that are not part of certain user groups.

I have a page I want to show to Admins/Mods/Subscribers only, what would I add?

Regards,
You'd need the PHP in templates plugin to do this in the templates themselves. If this new page has it's own PHP file, after global.php has been included, put this:

if(!in_array($mybb->user['usergroup'], array('3','4','6','X')))
{
     error_no_permission();
}

X would be the ID of the subscriber group.
(2010-04-10, 08:46 PM)MattRogowski Wrote: [ -> ]You'd need the PHP in templates plugin to do this in the templates themselves. If this new page has it's own PHP file, after global.php has been included, put this:

if(!in_array($mybb->user['usergroup'], array('3','4','6','X')))
{
     error_no_permission();
}

X would be the ID of the subscriber group.

I created the template and .php file myself, I do not understand where to attach the code you specified...


EDIT: Forget what I said, I was able to do it Smile