Skip to content

Instantly share code, notes, and snippets.

@patrickgilmour
Created June 20, 2014 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickgilmour/2be2195cda27d1fe7990 to your computer and use it in GitHub Desktop.
Save patrickgilmour/2be2195cda27d1fe7990 to your computer and use it in GitHub Desktop.
[WordPress] Remove custom capabilities in WordPress and Roles
/**
* Remove WordPress Capabilities
*
*/
add_action( 'admin_init', 'pgwp_clean_unwanted_caps' );
function pgwp_clean_unwanted_caps(){
$delete_caps = array('edit_issues', 'publish_issues', 'edit_other_issues', 'read_private_issues', 'delete_issue', 'edit_issue');
global $wp_roles;
foreach ($delete_caps as $cap) {
foreach (array_keys($wp_roles->roles) as $role) {
$wp_roles->remove_cap($role, $cap);
}
}
// Note: if you want to remove a Role at the same time
// $wp_roles = new WP_Roles();
// $wp_roles->remove_role( 'slug-of-role' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment