[resolved] Finding out if a user is the admin (6 posts)

  1. wiziology
    Posted 9 years ago #

    I am trying to create a custom page that can only be seen if the user is the admin. Is there a way to find out if a user is the admin WITHOUT the admin panel being displayed? I have tried is_admin() but that only works when the admin panel is showing and I tried the_author_login() but that can only be used within the loop.

  2. cam_oai
    Posted 9 years ago #

    i use this:

    $user_level = 10

    10 is admin


  3. wiziology
    Posted 9 years ago #

    awesome! works great! thanks!

  4. gr33nman
    Posted 8 years ago #

    First - I'm a newbie to WP.

    Here's a quick recipe edit for this plugin in order to add a link to the wp-admin from the widget instance when logged in as an administrator. It will look like this:

    Logout | Admin

    Current Line 125 of document /plugins/ajax-login/al_template.php:
    <a href="<?php echo get_settings('siteurl') . '/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']; ?>"><?php _e('Logout'); ?></a>

    Line 125 with edit:
    <a href="<?php echo get_settings('siteurl') . '/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']; ?>"><?php _e('Logout'); ?></a><?php global $userdata; get_currentuserinfo(); ?><?php if($userdata->user_level>9){ ?> | <a href="<?php echo get_settings('siteurl') ?>/wp-admin/">admin</a><?php } ?>

    I couldn't get 'is_admin()' to work, nor could I find examples in the codex, and I had to get_currentuserinfo() even though it had been done earlier in the template, but it works. There may be better methods. Please tell me.

  5. Kafkaesqui

    Posted 8 years ago #

    1. is_admin() is a conditional tag used to test if one is in the WordPress administration pages.

    2. Here's a recent thread where I point out how to test for admin privileges on the 'current' user:


  6. gr33nman
    Posted 8 years ago #

    Thanks, Kafkaesqui. Now I understand!

    Incidentally, the plugin I'm talking about is this one:

Topic Closed

This topic has been closed to new replies.

About this Topic