MyBB Community Forums

Full Version: Restricting Page Access by User Group
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!

Site: www.vampirecounts.net

I want to restrict access to certain areas of the site to members who have been around for a while and contributed.

The easiest way to do this seems to use the MYPS system (which I have), and then use the option to buy into Usergroups.

However I can only seem to be able to restrict access to forums, not pages. For example if I wanted to restrict the following page:

http://www.vampirecounts.net/invocation.php

So is there a way I can restrict such pages by usergroups?

Thank you
Put this anywhere after global.php has been included:

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

Note that this is telling it who is allowed; this would only allow super mods, admins and mods. To allow another usergroup, add the group ID to the array with ' and ' around it like the others.
Excellent!

Worked perfectly.

Thanks very much Matt.
Hi again,

In regards to the above code to restrict access. If I wanted to have a different page pop up when the user was refused access, such as one that I have created explaining why the can't access, how they can upgrade etc, how do I do that?
Probably better to redirect them rather than have a popup.

if(!in_array($mybb->user['usergroup'], array('3','4','6')))
{
    error_no_permission();
}
else
{
    redirect("url.php");
    exit;
}