MyBB Community Forums

Full Version: Adding or changing menu-top-links visible for registered users only...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Greetings community, 
Have a digging days in the code of MyBB forum to complete some tasks.
One of it is - how to change or what code need to write to index template or what appropriate plugin already existing for to add top menu link with custom icon, which are visible only for registered users on the forum.
I have take my time for searching this community tricks already discussed and search on google but do not find any easy integration steps.
Using the plugins like MyTabs is not a case, sorry...
I have already change the header template in the default theme and its header templates area, where add the link i need to 

					<ul class="menu top_links">
						<li><a href="https://MYFORUMURL.COM">MY_CUSTOM_LINK</a></li>
						{$menu_portal}
						{$menu_search}
						{$menu_memberlist}
						{$menu_calendar}
						<li><a href="{$mybb->settings['bburl']}/misc.php?action=help" class="help">{$lang->toplinks_help}</a></li>
					</ul>

But, occasions appear that this link is visible and clickable for everybody and have a public access. 
I want to place my custom link as the same kind as the Search link or Calendar link...
Which are visible and clickable when appears on the top of the board only when user is registered and have open session on the board, when it is guest or banned user I want its not visible and clickable on it. 
Does anybody had solved that case.?
board is 1.8 ver
Thank you
Did you add this in your HEADER template?
(2016-03-28, 02:53 PM)ArneVD Wrote: [ -> ]Did you add this in your HEADER template?

yes, I have added 
<li><a href="https://MYFORUMURL.COM">MY_CUSTOM_LINK</a></li>

in the code provided above at the <ul class="menu top_links"> area
it is works and link is visible and clickable, but issue is its visible and clickable for everybody..
As I have mentioned, task is to provide the access to that link only for registered users. 
The same as for
{$menu_search}
{$menu_calendar}

which are they only visible and clickable only for registered and authenticated on board users...
If you have PHP Conditionals installed then add this

<if $mybb->user['usergroup'] == 1 then><else><li><a href="https://MYFORUMURL.COM">MY_CUSTOM_LINK</a></li></if> 

instead of
<li><a href="https://MYFORUMURL.COM">MY_CUSTOM_LINK</a></li>

What this does is say if they are in usergroup one (which is guests) then show them nothing (hence the nothing after the then>) else (or otherwise) show all the other usergroups your custom link.

You can download PHP templates and conditionals here http://mybbhacks.zingaburga.com/showthread.php?tid=260
You can also just add this in your "Header_welcomeblock_member" template, which only shows the texts and links if you are logged in.
<if $mybb->user['usergroup'] == 1 then><else><li><a href="https://MYFORUMURL.COM">MY_CUSTOM_LINK</a></li></if>

commonly it is not work, still accessible for guests...

add url in the "Header_welcomeblock_member" template - temporarily helps, yes 
but how is to change icon now, it is always shown zoom icon, seems being as default...
adding <img> teg not helps

thank you guys, it will bring some light on template structure 
but better is to put URL on top of the board in the general menu... it is chat integration...

PHP conditions need to be installed on board? 
^ I'd suggest to install & use template conditionals plugin [NOT the php in templates plugin]
yes, I had installed this php template conditional and conditions works perfectly now
link appear only when user is authorised.
Thanks all you guys for this...

and maybe how to change icon for that url? ))
seems it is always showing zoom icon

so, I have used global.css where object described for the icon having using for representing the calendar, search and portal icons for top-links...
Now this case is solved completely.
Thanks a lot.