WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] $user_level question

[Resolved] $user_level question

  • I understand that 0 = subscriber and 1= contributer but for some reason this code

    >= 0 allows users not registered or logged in to view content

    shouldn’t this only be for those logged in ?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Not too sure what you are trying to accomplish–but you can use this to determine if user is logged in:

    <?php
    global $user_login;
    if( $user_login ) :
    ?>
    
    <?php your_code_blah_blah_blah; ?>
    
    <?php endif; ?>

    is it possible to list by user role ?

    ie

    if ( customrole1, customrole2, customrole3 )

    i have these all set to zero and just use the roles themselves

    unfortunately, that code is for listing a role, I’m looking for a hook to use for access purposes, am trying to stay away from having to enter a user level # since they are each level 0

    ie

    customrole1 > can see

    this

    else

    everybody else

    end

    I believe some plugin authors use ‘capabilities’ to test.

    if (current_user_can('import'))

    so guessing this might work:
    if (current_user_can('level_2'))

    Resource:
    Roles and Capabilities

    yea what i did was create a bogus capability and used the current_user_can worked beautifully thanks 🙂

    Can you explain this in a little more detail?

    Once you create a capability, how do you know what it’s name is?

    I mean, I know that I give it a name, but if I create a capability how do I know what to put in the ‘level_2’ area as noted here:

    if (current_user_can(‘level_2’))

    I tried putting in the obvious, the name of what I was doing, but that didn’t work. 🙁

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] $user_level question’ is closed to new replies.