Support » Developing with WordPress » Finding out if a user is the admin

Viewing 5 replies - 1 through 5 (of 5 total)
  • i use this:

    $user_level = 10

    10 is admin

    cheers

    awesome! works great! thanks!

    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:

    User_Identity
    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.

    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:

    http://wordpress.org/support/topic/153260#post-681600

    Thanks, Kafkaesqui. Now I understand!

    Incidentally, the plugin I’m talking about is this one:
    http://wordpress.org/extend/plugins/ajax-login/#post-2154

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Finding out if a user is the admin’ is closed to new replies.