Change WordPress user roles and capabilities Forums Bug Reports Trouble updating "Administrator" role

This topic contains 10 replies, has 2 voices, and was last updated by  berd0029 3 months, 4 weeks ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #5720

    berd0029
    Participant

    I’m running wordpress multisite – latest version of 5.2.2 and URE 4.5.1

    I’ve deactivated all plugins that were network activated

    I can click checkboxes and unlick checkboxes for all user roles, except administrator.

    On Administrator I can only check new roles, but not uncheck any roles.

    There are no errors shown in the browser console, and I’ve confirmed on two different sites (although they are similar).

    #5723

    Vladimir
    Keymaster

    URE does not allow revoke capabilities from administrator role in 2 cases:
    1) for single site WordPress
    2) for WordPress multisite when current user is not superadmin.

    This is done to prevent accidental lose of admin permissions.

    #5724

    berd0029
    Participant

    Hi Vladimir – those seems like good precautions. In my situation I am attempting to update the role of administrator from the network level /wp-admin/network/users.php?page=users-user-role-editor-pro.php

    and am logged in as a superadmin. I also tried from a second superadmin account to verify the problem.

    Nothing shown in error or debug logs related to URE.

    #5725

    berd0029
    Participant

    I should also add that I have been using URE for several years with no problems.
    I typically keep backups of old versions of plugins when I run updates, and I had version 4.47.2 saved. When I rolled back to this version, the problem was solved.

    #5726

    Vladimir
    Keymaster

    Good point. v. 4.51 does not allow to superadmin to edit ‘administrator’ role. It seems I tested JavaScript code from older version. It stopped working as expected after browser page refresh.
    I will investigate what was changed and why.

    #5727

    Vladimir
    Keymaster

    Quick workaround:
    open user-role-editor-pro/js/ure.js, go to line 552 and replace current:

    
    if ( ure_data.do_not_revoke_from_admin ) {
    

    with updated

    
    if ( ure_data.do_not_revoke_from_admin==1 ) {
    
    #5728

    Vladimir
    Keymaster

    Or course I will include this fix into the next update.

    #5729

    berd0029
    Participant

    I just tested logged in as Super Admin testing from root site, and in version 4.51 I still have the same problems as I do at network level. I Can add capabilities to Admin role, but not remove them.

    #5730

    berd0029
    Participant

    I tried the change you recommended, but it unfortunately did not solve the problem for me on the root site or at network level.

    	jQuery('.ure-cap-cb').each(function () { // go through all capabilities checkboxes
            if (this.id.length===0) {
                return;
            }
            jQuery(this).prop('checked', response.caps.hasOwnProperty(this.id) && response.caps[this.id]);
            if ( ure_data.do_not_revoke_from_admin==1 ) {  
                var el = document.getElementById(this.id);
                if ( 'administrator'===ure_current_role ) {
                    el.addEventListener( 'click', ure_turn_it_back );
                } else {
                    el.removeEventListener( 'click', ure_turn_it_back );
                }
            }
        });
    #5731

    Vladimir
    Keymaster

    Just be sure (re-check) that updated code was loaded at the testing page (force page refresh).

    #5732

    berd0029
    Participant

    Apologies but I had not done that. A shift +f5 to clear the browser cache solved the problem once the code was updated.

    Thanks for your quick response in solving this!

    best wishes,

    -Dan

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.