Created
June 20, 2014 00:03
-
-
Save patrickgilmour/2be2195cda27d1fe7990 to your computer and use it in GitHub Desktop.
[WordPress] Remove custom capabilities in WordPress and Roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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