• Resolved cloudstr210

    (@cloudstr210)


    Hello, I just want to check if the user is admin but I always got error..

    The error is unexpected > on the code..

    <?php if ( ! is_admin() ) {
    
    } else {
    }
    ?>

    I want to put adsense script on it.. But I always got unexpected >

    Thank you.

Viewing 5 replies - 16 through 20 (of 20 total)
  • Thread Starter cloudstr210

    (@cloudstr210)

    Thank you.. Problem solved!

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Big Bagel – I know, and yet… Anyway, I’m of the whatever works school ?? if (current_user_can( 'manage_options' )) is better, you’re right, but if it works, I don’t knock it. And either way? We needed to pull the adsense CODE out of the equation to figure out WHAT wasn’t working ??

    SwansonPhotos – WordPress. Four people, six opinions ?? It’s not a big deal really. Esmi and I wanted to see if his stuff worked without the adsense. We’re psychic, you see, and she knew my thought was that it wasn’t the if() code that was throwing up, but the adsense code ??

    Big Bagel

    (@big-bagel)

    I completely agree with using whatever works and pulling the adsense bit out while testing. ??

    However, if the goal was to hide the adsense code on the front end from administrators, if ( ! is_admin() ) wouldn’t work. It would always evaluate as true for any front end page regardless of the role of the current user.

    At the very least, whatever code cloudstr210 is now using resolved his problem, which is awesome sauce. ??

    Just to clarify the

    is_admin() function is used to check if you are in Admin area or in Front area.

    To check if the user is an Admin you should check his permissions !!

    hope this can help some one !

    I think is_super_admin() will do the trick

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Checking if the User is Admin’ is closed to new replies.