MyBB Community Forums

Full Version: How to add Navbar links with permissions ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible I can add links to the Navbar (I know how to works, but...) with usergroup permissions ?

Meaning, if i want to add a link to a specific site, but only want registered users to be able to get to this link by clicking on it, and not Guests for example ?

If that is possible, how would be the exact syntax ?

Thanks in advance.

Wolfseye
It would be possible by using the template conditionals plugin by Yumi: http://mybbhacks.zingaburga.com/showthread.php?tid=464

The syntax would then be something like this:

<if $mybb['usergroup'] != 1 then>
<li><a href="YOUR LINK">YOUR TEXT</a></li>
</if>

The above would simply hide the link from guests and show it to all other groups.
Wouldn't it be possible to, instead of hiding the link alltogether, to keep it there but get to a NO PERMISSION page ? The idea is for example adding things people might be interested in, but they would need to register for it. For that to know, they should see it as guest, the link. If they dont see it, they dont know that they might miss something.
It would be possible. What exactly are you looking to link to? If they're custom pages or pages added by plugins, you can simply do a check via PHP to see if they're a guest or not and use the error_no_permission() function.
Could you give me a example please ? I am not good with PHP and these things. Would appreciate your help in this greatly. Wink

Cheers

Wolfseye
Well, what kinds of things are you looking to link to exactly?
Nothing special. Just certain links to areas (dont even have to be with the forum) i want only people to get to with the right permissions. Its a more general purpose.

(2012-07-19, 03:55 PM)euantor Wrote: [ -> ]
<if $mybb['usergroup'] != 1 then>
<li><a href="YOUR LINK">YOUR TEXT</a></li>
</if>

Would that also allow for the use of more than one Usergroups or would it just be one ?
If you're wanting to use it on pages not actually linked with the forum at all then you might struggle unless you include ./global.php in order to determine the user's usergroup.

You could add more usergroups using OR/AND:

<if $mybb->user['usergroup'] != 1 AND $mybb->user['usergroup'] != 5 then>
<li><a href="YOUR LINK">YOUR TEXT</a></li>
</if>

The above would hide the links from unregistered members and members awaiting validation.