Support » Plugins » Getting User Level

  • I am writing a plugin that displays content only to admin user. To test if admin is logged in I trued using $user_level but the value I get is 0 instead of 10.

    This code:
    get_currentuserinfo() ;
    global $user_level;
    echo ‘user level: ‘.$user_level;

    Will echo out 0 when admin is logged in.

    What am I doing wrong?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Works fine for me.

    Note get_currentuserinfo() is not necessary; $user_level will already be available as a global var in the admin pages.

    It is not working for me.. But anyways, I just discovered I should be using


    for the same task.

    If I display all roles with wp_dropdown_roles() and user picks one (for example ‘editor’) how can I check later if the current user is ‘editor’?

    Anyone please?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Getting User Level’ is closed to new replies.