Change WordPress user roles and capabilities Forums Bug Reports New Role will not retain the ‘manage options’ setting

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7261
    mereagency
    Participant

    Every time I set this ‘manage options’ capability for my ‘Site Manager’ roles, it revokes as soon as I refresh the page. What’s strange is when I log in as the site manager in a different browser, the permissions are there for one page load, and then they reset.

    Site: studio.mere.site (theme demo)

    #7264
    Vladimir
    Keymaster

    Is ‘Site Manager’ role created by some plugin? I suppose the situation when that plugin recreates this role every time its loaded.
    What if you add ‘manage_options’ to any other role? Will it stay there?
    If Yes, use workaround – assign role with ‘manage_options’ to the user with ‘Site Manager’ role as the 2nd one.

    #7286
    mereagency
    Participant

    Hi Vladimir,
    Site Manager is a role I created in User Role Editor. But the plugin SEOPress seems to be revoking manage_options every time it is activated.

    #7289
    Vladimir
    Keymaster

    Hi,

    I can not repeat this.
    I tested SEOPress from wordpress.org and it did not remove ‘manage_options’ from my custom roles. I searched from its source code and did not find any commands related to ‘manage_options’ deletion.

    #7469
    mereagency
    Participant

    Hi Vladimir,
    I’m still having this problem. Is it possible to grant you access to one of the sites and show you what’s happening? When I add ‘manage options’, I see the user’s menus, etc change, but as soon as I load the page a second time, the option is remove.d

    #7470
    mereagency
    Participant

    This seems to happen with Simple Banner, I’ve filed a bug report with them specifically.

    #7471
    Vladimir
    Keymaster

    Hi,

    I confirm this. Simple banner plugin does not think that role may edited manually, and applies the logic: if role has ‘manage_simple_banner’ capability, thus it was granted automatically by SB plugin itself, then if role is not included into the list of roles allowed to work with SB (Pro feature), then automatically revoke ‘manage_simple_banner’ and ‘manage_options’ user capability from such role:

    
    // Add permissions for other roles
    foreach (get_editable_roles() as $role_name => $role_info) {
    	if ( $role_name !== 'administrator') {
    		if (in_array($role_name, explode(",", $permissions_array))) {
    			$add_role = get_role( $role_name );
    			$add_role->add_cap( $manage_simple_banner );
    			$add_role->add_cap( $manage_options );
    		} else {
    			$remove_role = get_role( $role_name );
    			// only remove capabilities if they were previously added
    			if ($remove_role->has_cap( $manage_simple_banner )){
    				$remove_role->remove_cap( $manage_simple_banner );
    				$remove_role->remove_cap( $manage_options );
    			}
    		}
    	}
    }
    
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.