• Hi,
    I am wondering how to show ads for users but not for admin(s). I want to hide Google Adsense and Google Analytics scripts since I won’t click ads or want to track myself.

    I have this snippet of code but it seems not to work as desired:

    <?php if ( !is_admin() ) : ?>
        Hide me
    <?php else : ?>
        show me
    <?php endif; ?>

    This bit of code doesn’t work, is there anything wrong with it?
    I also tried this script:

    <?php
    if ( is_user_logged_in() ) {
        echo 'Welcome, registered user!';
    } else {
        echo 'Welcome, visitor!';
    };
    ?>

    Which worked but I want members to see ads.

    Is there anyway to modify either bit of code to do as described?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • This bit of code doesn’t work, is there anything wrong with it?

    Yes – there’s isn’t an is_admin() conditional tag.

    You could try:

    <?php
    global $current_user;
    get_currentuserinfo();
    if ($current_user->user_level == 10 )echo 'Welcome, Admin';
    else echo 'Welcome!';
    ?>
    Thread Starter kickerman360

    (@kickerman360)

    Thanks esmi, worked perfectly!

    I did modify it slightly so if anyone wants this version, enjoy!

    <?php global $current_user; get_currentuserinfo(); if ($current_user->user_level == 10 ) { ?>
      Admin Stuff (In my case I left this blank)
    <?php } else {   ?>
      Stuff Seen By Visitors
    <?php } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘If Admin Hide Ads, If not, show?’ is closed to new replies.