Title: Accessing a custom capability
Last modified: August 19, 2016

---

# Accessing a custom capability

 *  Resolved [superdude](https://wordpress.org/support/users/superdude/)
 * (@superdude)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/accessing-a-custom-capability/)
 * Hi guys
 * I am entry level. Please help. I created a plugin, then i created a new custom
   capability from the Users, Capabilities page, it creates it and i can now choose
   which user can use it. Now for example say i decided user A get to use that capability,
   how do i check from my widget whether user A has been granted that right. I used
   if else statements but against what should i use it exactly. I created my capabilities
   as “Hbpediapublisher” and “Hbpediaeditor”, as you can see below what i am attempting
   to do is if i checked the box for user A’s profile which is Hbpediapublisher,
   it must set this variable myHbPediaLevel to 12 and elseif…..
 * Thanks!
 * `if ( current_user_can(‘Hbpediapublisher’) )
    { $myHbPediaLevel = “12”; } elseif(
   current_user_can(‘Hbpediaeditor’) ) { $myHbPediaLevel = “11”; } ?>

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [superdude](https://wordpress.org/support/users/superdude/)
 * (@superdude)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/accessing-a-custom-capability/#post-774195)
 * AFter some many hours of frustrating investigating, i found my answer. There 
   is a table called “wp_usermeta”, in there find the id of the person you are interested
   in. now if you have given them permissions to the custom capability you created,
   it will reflect here. this is where you will find it.
    1. Use sqlyog or whatever
   and run “select * from wp_usermeta” on the db 2. Then locate the user_id 3. look
   at the column named “meta_key” and look for “wp_capabilities”. 4. Now next to
   it the is a column named “meta_value”. 5. In my example above, my custom capability
   is “Hbpediapublisher” and “Hbpediaeditor”, and since i have allowed this user
   that capabilities, you will see “a:3:{s:13:”hbpediaeditor”;b:1;s:16:”hbpediapublisher”;
   b:1;s:13:”administrator”;b:1;}”
 * If they where not given those capabilities, you will see something like
    “a:1:{
   s:13:”administrator”;b:1;}”.
 * Hope this helps someone who was as lost as i.
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/accessing-a-custom-capability/#post-774225)
 * you’re not pulling this straight from the DB are you? – that’s completely unnecessary.
 * you don’t “check it against” anything… the current_user_can function does the
   checking for you.
 * so, once you’ve created the capability, you assign that capability to a user,
   and current_user_can checks whether this user has that capability.
 * that’s all… no custom queries into the database, no nothing.
 *  Thread Starter [superdude](https://wordpress.org/support/users/superdude/)
 * (@superdude)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/accessing-a-custom-capability/#post-774237)
 * i am actually, then i run a query in my custom php page to see if a user has 
   that capability in it, and if there is, i set my new php page to provide the 
   functionality based on that only. My whole plan is to create a new page, which
   is a link from my plugin on the main page, i pass the users variables to my new
   page, and then use the id to check in the db in that wp_usermeta table if they
   have the capability by checking for those values. I dont understand or am still
   getting to grips with how wordpress works, let alone php. I am 3 weeks into it
   from no experience. I am going to look over what you have said about he current
   user function and try to understand it like you guys do and get it done that 
   way.
 * thanks a mil for your help man! 🙂
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/accessing-a-custom-capability/#post-774297)
 * lets try to iron this out for you…
 * what do you think the “current_user_can” function does? It’s gotta do something
   right? otherwise it wouldn’t exist.
 * If you can cover that for me, that’ll be a great starting point from which to
   explain the process. I’m sure I’m going to be covering stuff you already know,
   but we need to start somewhere.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Accessing a custom capability’ is closed to new replies.

## Tags

 * [capabilities](https://wordpress.org/support/topic-tag/capabilities/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [ivovic](https://wordpress.org/support/users/ivovic/)
 * Last activity: [17 years, 11 months ago](https://wordpress.org/support/topic/accessing-a-custom-capability/#post-774297)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
