Change WordPress user roles and capabilities › Forums › Bug Reports › "Other Roles" w/ "Administrator" Not Working
Tagged: Other Roles
- This topic has 4 replies, 2 voices, and was last updated 8 years, 1 month ago by Vladimir.
-
AuthorPosts
-
05/10/2016 at 04:16 #2845sermonboxmediaParticipant
Hey There,
Have a quick question/problem. So I have a multisite environment and I’m attempting to limit the administrator role from having the ability to assign a specific role. However, when I attempt to block a role using the “other roles” tool, all roles still appear as options on the “users>new user” page?
I attempted to limit other roles and those seem to function correctly but I’m unable to limit the roles an administrator can assign?
Any help would be greatly appreciated!
06/10/2016 at 02:03 #2850VladimirKeymasterHi,
Currently User Role Editor Pro “Other Roles Access” add-on does not apply any restrictions for the users with ‘administrator’ role. My apologies for confusion as URE allows to edit the other role access restrictions for ‘Administrator’ role at the same time.
I will add a custom filter for this with a next update. So you may change this logic – apply other roles restrictions to the local administrators under multisite or not.
A quick workaround for current 4.28.2 version: open wp-content/plugins/user-role-editor-pro/pro/classes/other-roles-access.php file and comment lines 125, 126, 127, so you should get this code:
protected function blocking_needed() { global $current_user; // do not block data for superadmin $multisite = $this->lib->get('multisite'); if ($multisite && is_super_admin()) { return false; } // do not block data for local administrator //if ($this->lib->user_has_capability($current_user, 'administrator')) { // return false; //} // user can update access to other roles if ($this->lib->user_has_capability($current_user, self::other_roles_access_cap)) { return false; } ...
06/10/2016 at 02:26 #2851VladimirKeymasterTimeout. Recommendation above will not work. I search a solution.
06/10/2016 at 02:33 #2852sermonboxmediaParticipantHey Vladimir!
Thanks for the help on this! I saw you wrote that the above solution won’t work so I’ll be on the lookout for another solution from ya!! 🙂 thanks a ton!
06/10/2016 at 04:05 #2853VladimirKeymasterI developed a fix for this. It works conditionally now and takes an account the result from custom filter:
add_filter('ure_not_block_other_roles_for_local_admin','ure_block_other_roles_for_local_admin'); function ure_block_other_roles_for_local_admin($flag) { return false; }
You may add this code to the active theme functions.php file or setup it as a “must use” plugin.
In order this filter start to work you need to replace 3 files at current 2.28.2 version folder:
includes/classes/ure-lib.php
pro/includes/classes/other-roles-access.php
pro/includes/classes/ure-lib-pro.phpI will send the zip with updated files above to your email.
Of course this update will be included to the next version. Development version beta5 is on the road to the public testing stage currently (includes some unfinished changes) so I do not make it available for a while. -
AuthorPosts
- You must be logged in to reply to this topic.