Change WordPress user roles and capabilities Forums Bug Reports "Other Roles" w/ "Administrator" Not Working

Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2845
    sermonboxmedia
    Participant

    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!

    #2850
    Vladimir
    Keymaster

    Hi,

    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;
            }
    ...
    
    #2851
    Vladimir
    Keymaster

    Timeout. Recommendation above will not work. I search a solution.

    #2852
    sermonboxmedia
    Participant

    Hey 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!

    #2853
    Vladimir
    Keymaster

    I 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.php

    I 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.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.