I'm using this code inside a custom page:
<?php
if (is_member("4,6")){
} else {
error_no_permission();
}
?>
So that admins and users inside a group 6 can access content of the page.
It works fine with my Admin profile, but I created a test profile which belongs to group 6 (additional) while his primary one is Registered and he gets the no permissions page. How can I fix this?
I will create mutliple custom pages in future and would be impossible to allow users to access only certain ones using primary groups. I don't understand why the "is_member" fucntion seems to check only primary group and not additional nes
Try:
<?php
if (is_member("4","6")){
} else {
error_no_permission();
}
?>
(2015-05-27, 06:38 PM)Ben C Wrote: [ -> ]Try:
<?php
if (is_member("4","6")){
} else {
error_no_permission();
}
?>
Sorry it didn't change the result
define("IN_MYBB", 1);
require_once "global.php";
$groups = $mybb->user['usergroup'];
if($mybb->user['additionalgroups'])
{
$groups.= "," . $mybb->user['additionalgroups'];
}
$explodedgroups = explode(",", $groups);
$canview = 0;
$allowedgroups = array(4, 6);
foreach($explodedgroups as $group)
{
if(in_array($group, $allowedgroups))
{
$canview = 1;
break;
}
}
if(!$canview)
{
error_no_permission();
}
// Rest of page
(2015-05-27, 06:55 PM)dragonexpert Wrote: [ -> ]define("IN_MYBB", 1);
require_once "global.php";
$groups = $mybb->user['usergroup'];
if($mybb->user['additionalgroups'])
{
$groups.= "," . $mybb->user['additionalgroups'];
}
$explodedgroups = explode(",", $groups);
$canview = 0;
$allowedgroups = array(4, 6);
foreach($explodedgroups as $group)
{
if(in_array($group, $allowedgroups))
{
$canview = 1;
break;
}
}
if(!$canview)
{
error_no_permission();
}
// Rest of page
I had already declared that file was in mybb
However your code didn't work... my test profile got the nopermission message... it's like mybb only checks primary usergroup and not additional ones - i edited profile so that it displays group 6 but nothing -.
Is the person in the correct group? It uses both the primary usergroup and additional groups to see if the person is in usergroup 4 or 6. I don't use display groups because that is not what should be used for permissions. The code I provided doesn't use permissions of groups at all.
(2015-05-27, 07:09 PM)dragonexpert Wrote: [ -> ]Is the person in the correct group? It uses both the primary usergroup and additional groups to see if the person is in usergroup 4 or 6. I don't use display groups because that is not what should be used for permissions. The code I provided doesn't use permissions of groups at all.
Damn... my bad, your code did work in effect but i refreshed page (or didn't refresh?) and I couldn't see changes applied.... excuse me...
Issue is solved and your code is working