• Resolved wiziology

    (@wiziology)


    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.

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

    $user_level = 10

    10 is admin

    cheers

    Thread Starter wiziology

    (@wiziology)

    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:

    https://www.ads-software.com/support/topic/153260#post-681600

    Thanks, Kafkaesqui. Now I understand!

    Incidentally, the plugin I’m talking about is this one:
    https://www.ads-software.com/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.