MyBB Community Forums

Full Version: Finding the code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
<if $mybb->user['uid'] <= '0' then>

I want to show something to guests only. Not to other usergroups how can i do that?

<if $mybb->usergroup['gid'] <= '0' then> is correct? Should i add replace 0 with something?
<if $mybb->usergroup['gid'] == 5 then>
<p>welcome guest</p>
</if>
Na. Still isn't working. Anything else?
(2014-07-10, 06:45 PM)Afnan Wrote: [ -> ]Na. Still isn't working. Anything else?

<if $GLOBALS['mybb']->user['usergroup'] == 5 then>
<p>hello guest</p>
</if>

Try this, sorry I went off from what you had lol..
That code destroyed the whole forum lol. It wiped out the whole header.

This is the code in my header template which i'm editing. I want to show this to the guests. Tell me what i'm doing wrong. I suck at coding.
<div id="container">
		<hr class="hidden" />
		<br class="clear" />
		<div id="content">
<if $GLOBALS['mybb']->user['usergroup'] == 1 then> 
<div class="guestnotice">
<a href="member.php?action=login"><span class="guestbutton1"><i class="fa fa-key"></i> Login with an existing account</span></a>
<a href="member.php?action=register"><span class="guestbutton2"><i class="fa fa-heart"></i> Register an account</span></a>
Welcome to the forum! It seems like you're not registered.<br>
Why don't you take some seconds and register a free account? It's totally worth it!<br>
<ul>
<li>Meet over xxx other members.</li>
<li>Download over xxx resources.</li>
<li>Participate in more than xxx discussions.</li>
<li>And so much more - For free!</li>
</ul>
</div>
</if>
<br>

My guest group is actually 1.
(2014-07-10, 06:54 PM)Afnan Wrote: [ -> ]That code destroyed the whole forum lol. It wiped out the whole header.

This is the code in my header template which i'm editing. I was to show this to the guests. Tell me what i'm doing wrong. I suck at coding.
<div id="container">
		<hr class="hidden" />
		<br class="clear" />
		<div id="content">
<if $GLOBALS['mybb']->user['usergroup'] == 1 then> 
<div class="guestnotice">
<a href="member.php?action=login"><span class="guestbutton1"><i class="fa fa-key"></i> Login with an existing account</span></a>
<a href="member.php?action=register"><span class="guestbutton2"><i class="fa fa-heart"></i> Register an account</span></a>
Welcome to the forum! It seems like you're not registered.<br>
Why don't you take some seconds and register a free account? It's totally worth it!<br>
<ul>
<li>Meet over xxx other members.</li>
<li>Download over xxx resources.</li>
<li>Participate in more than xxx discussions.</li>
<li>And so much more - For free!</li>
</ul>
</div>
</if>
<br>

My guest group is actually 1.

Should be 5 not 1.
<if $GLOBALS['mybb']->user['usergroup'] == 1 then>

Also possibly a link would be helpfull to see what the error is doing.
It's a test forum anyway. I Pm'd you the link.
Couldn't you just do

If(!$mybb->user())
{
//your other stuff here
}

Of course this can't go in a template and you should push the results through a template as well
(2014-07-10, 07:10 PM)Dannymh Wrote: [ -> ]Couldn't you just do

If(!$mybb->user())
{
//your other stuff here
}

Of course this can't go in a template and you should push the results through a template as well

OP wants to display the text to guests only. So we would have to do:
if $mybb->user == 5
Urgghh and php directly in templates, I still feel is a bad idea. There should be no reason to have php in your templates presentation and logic layers should be completely separate.

If you don't want it to show for non-guests then you just don't push anything into the template variable
Pages: 1 2