Codex

Function Reference/remove cap

Contents

Description

Removes a capability from a role.

Usage

 <?php remove_cap$role$cap ); ?> 

Parameters

role
(string) (Required) role name
Default: None
cap
(string) (Required) capability name
Default: None

Example

add_action( 'admin_init', 'remove_editor_read_private_posts' );

function remove_editor_read_private_posts(){
  global $wp_roles;
  $wp_roles->remove_cap( 'editor', 'read_private_posts' );
}

NB: This setting is saved to the database, so it might be better to run this on theme/plugin activation (and then undo on de-activation)?

Notes

Changelog

Source File

remove_cap() is located in wp-includes/capabilities.php.

Related

Roles and Capabilities: add_role(), remove_role(), get_role(), add_cap(), remove_cap()

See also index of Function Reference and index of Template Tags.