MyBB Community Forums

Full Version: Disable My Advertisements on Login/Lost PWD/Register pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi folks,

I've got My Advertisments setup and running nicely. I'd like to disable ads from displaying on my login/registration/user CP/lost password pages so as not to violate Google Adsense TOS.

How do I do this? I'm happy use PHP conditional statements but just don't know how to do so in MyBB.

J
Download Template Conditional and after use this code in the header and footer templates

<if THIS_SCRIPT != 'member.php' || $GLOBALS['mybb']->input['action'] != 'register' then>
Your ads code here
</if>
Great, that's fixed it for the registration page, but not for the lost password or user CP. What can I do about those?

J
Would be easier and safer to simply comment out the hooks for those pages in the plugin file...

Template Conditionals is a security risk if you don't know what you're doing with it.
Thanks for the advice...the ads are being called in the header, footer and postbit templates though so I don't think your message will work, will it?
Perhaps not, I have no experience with the plugin. But still better to put code into the plugin file instead of using template conditionals, which in addition to being dangerous of you don't understand it, also requires all the overhead of another plugin.

The code he gave you can be used inside the plugin file in a manner like this:
At start of function after any globals put:
if(THIS_SCRIPT == 'member.php' || THIS_SCRIPT == 'usercp.php')
{
   return;
}

You can add more places by finding out the THIS_SCRIPT for that page (located at the top of each php file, but should match the filename) and putting another || THIS_SCRIPT == 'filename.php' in the if statement.