I want to disable a plugin for authors

Discussion in 'WordPress' started by otjutt, Feb 25, 2011.

  1. #1
    Hello guys!

    Guys I want to disable plugin 'whydowork' adsense for non-admin so that whenever I post an article adsense ads should be displayed and whenever an author (non-amin) posts an article adsense ads should not displayed.

    Thanks!
     
    otjutt, Feb 25, 2011 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think the easiest way is to add a test function to the template.
    The plugin excludes ads when <!-no-adsense--> appears in the post.

    This line should add it to non-admin posts. I would place it after <?php the_content(); ?>
    <?php if (get_the_author_meta('user_level') != 10 ) echo '<!-no-adsense-->'; ?>

    Hope that works :)
     
    Cash Nebula, Feb 26, 2011 IP
  3. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #3
    On second thought, that probably won't work because it's outside the content and the plugin won't see it.

    Try adding this to functions.php instead
    
    /**
     * Adds comment to non-admin posts so that WhyNotWork plugin does not insert ads
     */
    function add_adsense_comment($content = '') {
    	if (get_the_author_meta('user_level') != 10 ) $content .= '<!-no-adsense-->'; 
    	return $content;
    }
    
    add_filter('the_content', 'add_adsense_comment');
    
    Code (markup):
     
    Cash Nebula, Feb 26, 2011 IP