WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just realized the following:

// Call the current user info
global $current_user;

// Add a capability
// and set the 2nd argument ($grant) to false
$current_user->add_cap( 'some_cap', false ); 

Now I've successfully added a capability to the user, but denied her/him the access to this capability.

If I now check with $current_user->has_cap( 'some_cap' ); I'd get a true in return. The same goes for current_user_can( 'some_cap' ); as this is only a wrapper for the has_cap functions arguments.

Q: Where is the 2nd argument used? Did I get something wrong?

share|improve this question
up vote 3 down vote accepted

I think you are using it right. I think it is actually a bug in WordPress.

When you do the same for roles $somerole->add_cap( 'some_cap', false );, it works as expected.

share|improve this answer
Thanks for looking into this. +1 – kaiser Nov 22 '11 at 19:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.