Web Developer. Computer Programmer. Geek.

Hiding AdSense from Administrator

For the longest time (actually only 4 months), I’ve been trying to find a way to hide Google’s AdSense ads from myself. They serve no purpose for me, as clicking on them is a violation of the TOS. Today, I was reading an article at Performancing that, more or less, demonstrated how to accomplish this.

By design, I’m the only registered user on any of my blogs. That means, if I hide the ads from all registered users, I will be hiding the ads from myself, but allowing everyone else to see them and hopefully click on them.

Hide from All Registered Users


< ?php if (!($user_ID > 0)) { ?>
Insert AdSense code here
< ?php } ?>

After you remove the space between the left bracket (<) and question mark (?) on each php line, you’ll be set. It’s a surprisingly simply solution but completely effective.

In the next few days, I’ll post a few similar php snippets that I’ve used to get the most of my AdSense channels.

Update 9:15 pm: I ran into an issue while updating this site with the above technique. After adding the code above to the sidebar.php page, I was still seeing the ads. If you are running into a similar problem, try using the following code.


< ?php global $user_ID;
if (!($user_ID > 0)) { ?>
AdSense code here
< ?php } ?>

Comments are closed.