How To Disable AdSense Ads For Logged In WordPress Users

How To Disable AdSense Ads For Logged In WordPress Users
How To Disable AdSense Ads For Logged In WordPress Users Image by: mydotcomreviews.com

If you make money from adsense, you will know that some invalid adsense activities could get your account banned. Invalid activities can include clicking on your on ads, self generated impression, Click fraud, invalid traffic and many more others.

I recently got my adsense account banned in a wordpress blog, due to unintentional self generated impression generated by my admin and authors. In a conscious move to ensure that this problem doesn’t occur again, I have been doing research on the How To Disable AdSense Ads For Logged In WordPress Users. If you’re running AdSense Ads on a WordPress site then you may wanna disable Ads for logged in WordPress users, to avoid google hammer.

If advertisements are permitted to logged into WordPress users then the author might indirectly inflate ad impressions or he might click a Ad by error.

This can be a critical problem since inflating clicks or ads is strictly against Google AdSense Policies. So its best to disable advertisements to logged in WordPress users.

Also if you target the advertisements only towards people instead of writers then it could dramatically increase the performance of ads on your website.

So in this post I will discuss how to disable AdSense ads to logged in WordPress users in addition to how to disable advertisements on Post Preview Page.

#1) Hide Ads Only For Logged In Users

Include the following Code to show Adsense Ads. Just put the ad code inside the PHP conditions. So the AdSense ad will be only displayed to logged into WordPress users.

PHP
1
2
3
4
5
<?php if(!is_user_logged_in()) { ?>
 
Adsense_Code_Goes_Here
 
<?php } ?>

This may work in almost any .php file like Single Article file. But if you’re putting an advertisement in Widget then that fails because the code is PHP.

If you’d like this to operate in Widgets then it’s possible to use a plugin called’Executable PHP Widget’.

If you don’t need to use any plugin then check my post on the way to execute PHP code from WordPress widget.

#2) Disable Ads In Preview Mode

To disable advertisements in preview mode, you need to again utilize the same idea of PHP state but slightly different code. This code simply checks if preview mode is on or not. Otherwise then displays the advertisement.

PHP
1
2
3
4
5
<?php if (!is_preview()) { ?>
 
Adsense_Code_Goes_Here
 
<?php } ?>

And since this is a PHP code, it will not operate in Widget unless you use a plugin or modify the purposes of your own theme.

ALSO SEE:

About umoh

The CEO and founder of Business Ideas Incubation Services.Our services includes: Professional business plan writing for venture capital, market research and analysis, Feasibility studies and startup business consulting.+2348140970926

Leave a Reply

Your email address will not be published.