Editors can only edit Subscribers profiles
-
Hi fellows,
I would like my editor to manage the subscribers ONLY. So far I managed to give them the capabilities, and restrict their role attribution to “Subscribers” only. But It’s still possible for them to remove my Admins roles !
register_activation_hook( __FILE__, 'editors_edit_users_activation' ); function editors_edit_users_activation () { foreach ( array( 'editor' ) as $r ) { $role = get_role( $r ); if ( $role ) { $role->add_cap( 'create_users' ); $role->add_cap( 'edit_users' ); $role->add_cap( 'delete_users' ); $role->add_cap( 'list_users' ); } } } register_deactivation_hook( __FILE__, 'editors_edit_users_deactivation' ); function editors_edit_users_deactivation() { foreach ( array( 'editor' ) as $r ) { $role = get_role( $r ); if ( $role ) { $role->remove_cap( 'create_users' ); $role->remove_cap( 'edit_users' ); $role->remove_cap( 'delete_users' ); $role->remove_cap( 'list_users' ); } } } add_filter( 'editable_roles', 'editors_edit_users_filter_roles' ); function editors_edit_users_filter_roles( $roles ) { $user = wp_get_current_user(); if ( in_array( 'editor', $user->roles ) ) { $tmp = array_keys( $roles ); foreach ( $tmp as $r ) { if ( 'subscriber' == $r ) continue; unset( $roles[$r] ); } } return $roles; }
(https://gist.github.com/chrisguitarguy/1804462)
[Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
So I would like to hide other roles profiles (contributors, administrators…) for “editors”… : Is there a way to avoid editors with extended capabilities to see non-subscribers in the users.php part of the admin panel ?
Thanks for any answer or advice.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Editors can only edit Subscribers profiles’ is closed to new replies.