• Hi. I use this for a members only page:
    <?php if(is_user_logged_in()): ?>

    I am wondering if there is another one for administrators rank only?

Viewing 4 replies - 1 through 4 (of 4 total)
  • You can use the current_user_can function:

    <?php
    if ( current_user_can( 'activate_plugins' ) ) {
        // do stuff
    }
    ?>

    This assumes that only your administrator can activate plugins. Just choose any capability that you know is unique to your admin user.

    Ah, just discovered you can do the following which is even better:

    <?php
    if ( current_user_can( 'administrator' ) ) {
        // do stuff
    }
    ?>
    Thread Starter Ashkir

    (@ashkir)

    Thank you LumpySimon! I’ll test it now.

    Thread Starter Ashkir

    (@ashkir)

    That worked wonderfully. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Administrators only page?’ is closed to new replies.