MyBB Community Forums

Full Version: Question about "$mybb->usergroup"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everybody!
I just began working with myBB, currently I'm working on embedding a chat into the forum (kinda like a shoutbox).
Because I had no idea how to do this I checked out how it was done in another mod ("usermap").

There's one line I don't understand:
if($mybb->usergroup['canviewusermap'] != "1")

what is this: $mybb->usergroup['canviewusermap']
It seems like it has nothing to do with the "normal" usergroups like Admin/Mod/Guest.
Where can I find more information about this array and how to work with it?

Thanks!
The $mybb->usergroup array holds information on the usergroup of whoever is viewing the page. It loads the relevant array from the usergroups cache. Have a look at ACP > Tools & Maintenance > Cache Manager > usergroups. There's an array for each group, just loads the one for the group the user is in. For example if you put this:

echo $mybb->usergroup['gid']; //echo the GID of the group

it'd echo 1 for guests, 2 for registered, 4 for admins etc... so the code you posted would check if the usergroup of whoever is viewing the page can view the usermap.

Hope that helps.
Big thanks, thats exactly what I wanted to know!