MyBB Community Forums

Full Version: Allowing certain usergroups to view certain links using if else php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Right, here's the deal. I know you can make certain things show up for certain members. For example:

if($mybb->user['uid'])
{
     // Registered Stuff
echo "This will appear if you are online";
}
else
{
echo "This will appear if you are not";
}

and
if($mybb->usergroup['cancp'])
{
     // Admin stuff
echo "This will appear if you are an admin";
}
else
{
echo "This will appear if you are not";
}

So, I was trying to make this work for separate user groups. Such as custom ones, using their GID, in example:

if($mybb->user['usergroup'] = "9")
{
     // Usergroup Stuff
echo "This will appear if you are in this specific usergroup";
}
else
{
echo "This will appear if you are not";
}

However, to my surprise, this doesn't work. Anybody know how? Because I'm incredibly confused.

Cheers.
= should be ==

Right now it'll show for everybody as it's setting the value of $mybb->user['usergroup'] to 9, which it will do, thus the if statement will return true and it'll execute the first piece of code.
Wow. Brilliant. Will this only count for people who's primary usergroup is set, or will it also show up for anybody who has the usergroup as their additional?
It'd only check their main usergroup. To check the additional too, use this:

if($mybb->user['usergroup'] == "9" || in_array(9, explode(",", $mybb->user['additionalgroups'])))