How To Restrict Access To Any Page
#1
Hello,

In this basic tutorial I will be showing you have to restrict access to any page on MyBB to certain user groups.

1. Go to your forums root and find the page / file you want to restrict.
2. Open it with NotePad++ or something like that.
3. Add this code to the file

$allowed = array('4','3','6','12','13'); // The numbers are the usergroup IDs

if(!in_array($mybb->user['usergroup'], $allowed))
{
	error('You are not allowed to access this page.', 'Page Name');
}

4. Change the numbers to the user group IDs that are allowed to access the page.
5. Change the error message and the page name.

That's it save the file and place it back into your forums root.
Reply
#2
Shouldn't it be ERR_NO_PERMISSION or something similar?
Reply
#3
(2018-03-25, 10:16 PM)Ben Cousins Wrote: Shouldn't it be ERR_NO_PERMISSION or something similar?

I think by using that it uses the MyBB default no permission page this is for if you want to use a custom error message.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)