MyBB Community Forums

Full Version: Hiding based on permissions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok. After perusing the system a bit, I noticed that I can make the member list, search, calendar and help sections unavailable to specific permission-groups.

However, all though I make them unavailable, they still see the links. That's somewhat annoying. Is there a way to hide anything that's not available so that the user who doesn't have access doesn't even know its available in the first place?
hmmm. I was going to say you need to edit the templates, but doing that would make it go for all people... I know some things disappear when you switch things off, but not all. I'd submit some bug or feature requests over on the main site. If they say it's intended that way, say it shouldn't be Toungue
There is a way by combining HTML and PHP however it needs abit of handy work.

Go to Admin CP > Templates > Modify / Delete > Global Templates / Add template

Make the title top_links

and the content as follows
<div class="menu">
				<ul>
					<li><a href="{$mybb->settings['bburl']}/search.php"><img src="{$mybb->settings['bburl']}/{$theme['imgdir']}/toplinks/search.gif" alt="" />{$lang->toplinks_search}</a></li>
					<li><a href="{$mybb->settings['bburl']}/memberlist.php"><img src="{$mybb->settings['bburl']}/{$theme['imgdir']}/toplinks/memberlist.gif" alt="" />{$lang->toplinks_memberlist}</a></li>
					<li><a href="{$mybb->settings['bburl']}/calendar.php"><img src="{$mybb->settings['bburl']}/{$theme['imgdir']}/toplinks/calendar.gif" alt="" />{$lang->toplinks_calendar}</a></li>
					<li><a href="{$mybb->settings['bburl']}/misc.php?action=help"><img src="{$mybb->settings['bburl']}/{$theme['imgdir']}/toplinks/help.gif" alt="" />{$lang->toplinks_help}</a></li>
				</ul>
			</div>

This same code can be found in the header template, so replace it in the header template with
{$top_links}

Now open global.php

Find

eval("\$header = \"".$templates->get("header")."\";");
Above it add
if($mybb->user['usergroup'] == 4)//Allowed groups
{
	eval("\$top_links = \"".$templates->get("top_links")."\";");
}

Note that when we say

$mybb->user['usergroup']

It means the group of the user who is browsing the site, therefore in this if statment include only those who have permissions to see the links, for example


if($mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 3)//Allowed groups
{
	eval("\$top_links = \"".$templates->get("top_links")."\";");
}
This way it works for both admins and super mods. You can add additional groups, you only need the group id.
Nice. Thank you. I'll try it now.