Title: $user_level question
Last modified: August 18, 2016

---

# $user_level question

 *  Resolved [ringostar](https://wordpress.org/support/users/ringostar/)
 * (@ringostar)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/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)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/user_level-question/#post-651219)
 * 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; ?>
       ```
   
 *  Thread Starter [ringostar](https://wordpress.org/support/users/ringostar/)
 * (@ringostar)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/user_level-question/#post-651466)
 * 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
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/user_level-question/#post-651467)
 * This might have some info:
    [http://wordpress.org/support/topic/141334?replies=7](http://wordpress.org/support/topic/141334?replies=7)
 *  Thread Starter [ringostar](https://wordpress.org/support/users/ringostar/)
 * (@ringostar)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/user_level-question/#post-651475)
 * 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
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/user_level-question/#post-651476)
 * 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](http://codex.wordpress.org/Roles_and_Capabilities)
 *  Thread Starter [ringostar](https://wordpress.org/support/users/ringostar/)
 * (@ringostar)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/user_level-question/#post-651477)
 * yea what i did was create a bogus capability and used the current_user_can worked
   beautifully thanks 🙂
 *  [Clicknathan](https://wordpress.org/support/users/clicknathan/)
 * (@clicknathan)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/user_level-question/#post-651539)
 * 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 ‘$user_level question’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [Clicknathan](https://wordpress.org/support/users/clicknathan/)
 * Last activity: [18 years, 5 months ago](https://wordpress.org/support/topic/user_level-question/#post-651539)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
