Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created October 12, 2010 01:58
Show Gist options
  • Save mjangda/621541 to your computer and use it in GitHub Desktop.
Save mjangda/621541 to your computer and use it in GitHub Desktop.
Add necessary caps to admin and editor roles to manage usergroups
add_action( 'admin_init', 'ef_usergroups_cap_fix' );
function ef_usergroups_cap_fix() {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
// Add necessary capabilities to allow management of usergroups and post subscriptions
// edit_post_subscriptions - administrator + editor
// edit_usergroups - adminstrator
if( $wp_roles->is_role('administrator') ) {
$admin_role =& get_role('administrator');
$admin_role->add_cap('edit_post_subscriptions');
$admin_role->add_cap('edit_usergroups');
}
if( $wp_roles->is_role('editor') ) {
$editor_role =& get_role('editor');
$editor_role->add_cap('edit_post_subscriptions');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment