WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] $user_level for admin account returned as 0? (3 posts)

  1. SteelFrog
    Member
    Posted 4 years ago #

    Hey there, folks.

    I'm trying to write a short condition-based sidebar menu for my blog. I'm trying to add a few options only available to user accounts level 1 and up. While it works fine for all other accounts, my admin account returns a value of 0 when I call $user_level.

    Here's how I get the value:
    <?php global $user_ID, $user_email, $user_identity, $user_level; ?>

    I then use that value here:
    <?php if ( $user_level >= 1 ) : ?>

    I checked the user_level by doing a simple print. Any ideas why the admin account returns as 0 rather than 9 (or is it 10?)

  2. t31os
    Member
    Posted 4 years ago #

    Levels are for backwards compat, determine the role instead.

    The approach here would be easy to adopt.
    http://wordpress.org/support/topic/275681?replies=19

  3. SteelFrog
    Member
    Posted 4 years ago #

    Thank you! I knew this had changed but I couldn't find any proper documentation on it. Appreciate the help!

Topic Closed

This topic has been closed to new replies.

About this Topic