MyBB Community Forums

Full Version: Check if user is inside certain additional usergroups
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There are 3 pages which i want to restrict inside my forum, they're located at /misc.php?page=pagename (i'm using PageManager plugin).

I also have 3 usergroups which i want to be the only ones that can access the pages, in this way:

usergroup1 (gid=13) must only access page1
usergroup2 (gid=14) must only access page2
usergroup3 (gid=16) must only access page3

Here it comes to the problem.
I'm using this code in page1:

if (is_member("1,2,14,16")) {
die("<br><i>You cannot access this content.</i><br>");

And this other in page2 and page3
if (in_array($mybb->user['usergroup'] , array(1,2,etc..))) {

die("<br><i>You cannot access this content.</i><br>");
}

But both only grant access if the user is currently displaying the allowed group, so what should i do to check if user is a member of allowed groups, but isn't displaying them, and allow him access?
You could try it the other way.

Page 1
<?php
if (is_member("3,4,6,13")){
	// Content of page 1 //
} else {
	error_no_permission();
}
?>

Page 2
<?php
if (is_member("3,4,6,14")){
	// Content of page 2 //
} else {
	error_no_permission();
}
?>

Page 3
<?php
if (is_member("3,4,6,16")){
	// Content of page 3 //
} else {
	error_no_permission();
}
?>
(2015-01-10, 01:38 AM)SvePu Wrote: [ -> ]You could try it the other way.

Page 1



<?php
if (is_member("3,4,6,13"){
	// Content of page 1 //
} else {
	error_no_permission();
}
?>

Page 2



<?php
if (is_member("3,4,6,14"){
	// Content of page 2 //
} else {
	error_no_permission();
}
?>

Page 3



<?php
if (is_member("3,4,6,16"){
	// Content of page 3 //
} else {
	error_no_permission();
}
?>

Sorry for late reply, tried your code and got this:
[Image: Mhl4EPD.png]


[Image: 6a9662d468b1fba5829c0f15cdf4770e.png]
Pls send me your custom php page via PM, I guess you have a script error in it.
(2015-01-12, 04:33 PM)SvePu Wrote: [ -> ]Pls send me your custom php page via PM, I guess you have a script error in it.

PM sent, gope to sort this out Smile
You have an unmatched parenthesis in the if line for page1, page2, and page3.
(2015-01-12, 05:36 PM)dragonexpert Wrote: [ -> ]You have an unmatched parenthesis in the if line for page1, page2, and page3.

You're right ... it was a copy/paste issues Shy

Fixed it!