MyBB Community Forums

Full Version: Code Only Viewable To Guests
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am looking to put some code on a few of my pages that I only want guests to be able to view.

Is there a standard opening and closing tag/piece of code that I can put so that anything in between is only viewable to guests?

Thanks,

James
Using the PHP in Templates plugin, this should work:

<if $mybb->user['usergroup'] == 1 then>
// Content
</if>
Thanks for the reply.

I've took your code and put mine inside (see below) but it's just showing up for all users, any ideas?

This is my code:

<if $mybb->user['usergroup'] == 1 then>
<br />
To hide this advert please <a href="http://www.new-606.co.uk/member.php?action=register">REGISTER</a> or LOGIN.
<br />
<!-- Begin: AdSense -->
<script type="text/javascript"><!--
google_ad_client = "ca-pub-5297545259524109";
/* New-606 Showthread Ad */
google_ad_slot = "9155606496";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<!-- End: AdSense -->
</if>
Try this:

<if $GLOBALS['mybb']->user['usergroup'] == 1 then>
// Content
</if>
Oh God no it completely messed up my site and have this error on the top:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/uroxgam1/public_html/new-606.co.uk/global.php(500) : eval()'d code on line 1108
Maybe it's easier to use a plugin.
I use IndexAds Plugin to add on the header of the index site the advertisement.
Changing the plugin to "only show to guests" is a quick task and should do what you need.
Also adding these Plugin on other sites like "showthread" isn't difficult.

So maybe this is the way you should do...
Thanks I'll look into it! Smile
(2011-08-26, 05:34 PM)Kapsonfire Wrote: [ -> ]Changing the plugin to "only show to guests" is a quick task and should do what you need.

How do I do this?

Thanks
Could someone please help here before it goes off the page? Smile