Hiding Ads on Your Site

August 2, 2009 No Comments

I wanted to hide my ads. Well acutually just from myself. I read somewhere once about decreasing some risk of clicking your own Adsense ads. So I found this snip of code on the net:

if (!is_user_logged_in()) {
// Insert Adsense (or whatever) code here
}

Cool right…!? Wait a minute. That removes the ads for all users of my site. It would seem to me if someone is a subscriber to my site, I might want to target those individuals. They must be interested in what I have to offer and took the time to register at my site. I want them to see my ads… right?

This is what I came up with:

<?php
if ($current_user->user_level < 2){
?>
//add html code here.
<?php
}
?>

This will show ads to everybody below the Author user role. If you use html pasted into the function leave the ?> and <?php. If you use php to generate the code you should remove the ?> and <?php. For more information on User Levels, Roles and Capabilities check it out from the source. http://codex.wordpress.org/Roles_and_Capabilities

WordPress, general, themes

Leave a Reply

You must be logged in to post a comment.

Car Computing and My 300

I love my 300. I always try to drive it over my Montana SV6 (not a very hard decision)....

Print CSS

I really don’t like the “Printer Friendly” icons. Don’t you think when you hit print it should just print?...

Hiding Ads on Your Site

I wanted to hide my ads. Well acutually just from myself. I read somewhere once about decreasing some risk...

Disabling Auto Save

I find the WordPress autosaving function a little annoying. Usually I write my postings or pages on OpenOffice Writer...