I'm on Wordpress 3.0 and I can't seem to remove a capability from a specific user by the means provided here: http://www.garyc40.com/2010/04/ultimate-guide-to-roles-and-capabilities/

Also, what hook would be good to call it on? I'm calling on admin_init but maybe I should call it on different one.


  • Please provide more details, like what role ( or name?) and capability.
    – Wyck
    May 9, 2011 at 22:49

1 Answer 1


the page you linked shows how to remove a capability from a role:

global $wp_roles;
// remove capability $cap from role $role
$wp_roles->remove_cap( $role, $cap );

and an example would be:

// for example
$wp_roles->remove_cap( 'subscriber', 'view_galleries' );

or remove a capability from a specific user:

// get the user by username say for example its admin
$user= new WP_User( null, 'admin' );
// remove a capability from the user
$user->remove_cap( 'view_galleries');

as for what hook you should use, you don't need any just paste this code once in your theme's functions.php file, save and remove, since the roles and capabilities are saved in the database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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