Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Thanks!

share|improve this question
    
Please provide more details, like what role ( or name?) and capability. –  Wyck May 9 '11 at 22:49
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

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.