MyBB Community Forums

Full Version: Hide text from logged in users.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all, I've been looking for hours for a solution but have yet to find one,

can someone please tell me, how can I hide text from logged in users in a template?

I have not launched my site yet and any help would be greatly appreciated.
what and where exactly you want to hide... anything that goes into ACP >> Templates >> Header Templates >> header_welcomeblock_guest will be shown only to guests, but in all pages... if you want to show some text to guest in specific pages then you need to use PHP in templates or Template Conditionals
(2014-10-19, 09:08 AM)mmadhankumar Wrote: [ -> ]what and where exactly you want to hide... anything that goes into ACP >> Templates >> Header Templates >> header_welcomeblock_guest will be shown only to guests, but in all pages... if you want to show some text to guest in specific pages then you need to use PHP in templates or Template Conditionals

Hi and thank you for replying, and for the links Smile
but the issue is, I put the "Login Register"in the header,

	<ul class="menu top_links">
                   <li><a href="{$mybb->settings['bburl']}/member.php?action=login" onclick="$('#quick_login').modal({ fadeDuration: 250, keepelement: true }); return false;" class="login">{$lang->welcome_login}</a> <a href="{$mybb->settings['bburl']}/member.php?action=register" class="register">{$lang->welcome_register}</a></li>
					</ul>

but when I log in, I can still see the "Login Register" in the header and I want to hide it from logged in members.

I found this code in php but it didn't work
<?php if($mybb->user['uid'] == 0){ print "You are a guest!";} ?>

what do you think? Any pointers would be appreciated.
You should put the login/register in header_welcomeblock_guest template as mmadhankumar said, then it will affect only guests. Also make sure that {$welcomeblock} is in the header template if it doesn't display.
(2014-10-19, 11:38 AM)Destroy666 Wrote: [ -> ]You should put the login/register in header_welcomeblock_guest template as mmadhankumar said, then it will affect only guests. Also make sure that {$welcomeblock} is in the header template if it doesn't display.

Hi destroyer666, I just want to say thanks for taking the time to answer me, okay I will check out your solution using the header block! Brilliant suggestions!

(2014-10-19, 10:42 AM)Michael2014 Wrote: [ -> ]
(2014-10-19, 09:08 AM)mmadhankumar Wrote: [ -> ]what and where exactly you want to hide... anything that goes into ACP >> Templates >> Header Templates >> header_welcomeblock_guest will be shown only to guests, but in all pages... if you want to show some text to guest in specific pages then you need to use PHP in templates or Template Conditionals

Hi and thank you for replying, and for the links  Smile
but the issue is, I put the "Login Register"in the header,


 <ul class="menu top_links">
                   <li><a href="{$mybb->settings['bburl']}/member.php?action=login" onclick="$('#quick_login').modal({ fadeDuration: 250, keepelement: true }); return false;" class="login">{$lang->welcome_login}</a> <a href="{$mybb->settings['bburl']}/member.php?action=register" class="register">{$lang->welcome_register}</a></li>
 </ul>

but when I log in, I can still see the "Login Register" in the header and I want to hide it from logged in members.

I found this code in php but it didn't work

<?php if($mybb->user['uid'] == 0){ print "You are a guest!";} ?>

what do you think? Any pointers would be appreciated.


FYI: When I downloaded the plugin PHP in teplates, this code to hide text,worked perfectly
<?php if($mybb->user['uid'] == 0){ print "You are a guest!";} ?>