WordPress.org

Ready to get started?Download WordPress

Forums

User Role Editor
Not able to add ability to edit users (15 posts)

  1. Sjobidoo
    Member
    Posted 1 year ago #

    After updating to 3.4.1 I'm not able to add the ability to edit users anymore to the Editors / lower roles than Admin...

    They can list the users and remove them..but for some reason, they cannot edit any users.

    http://wordpress.org/extend/plugins/user-role-editor/

  2. Sjobidoo
    Member
    Posted 1 year ago #

    To clarify a bit: I'm able to add the ability..but it has no effect.

    The user is listed to have all abilities regarding editing, deleting, adding etc other users...but he can only list users and not edit any of them.

  3. Sjobidoo
    Member
    Posted 1 year ago #

    Using a multisite installation.

    Any response from the developer on this issue would rock :)

  4. Sjobidoo
    Member
    Posted 1 year ago #

    Solved this issue.

    It's not enough to merely add the capability to edit users when on a multisite installation. In case any others encounter this or the developer (hopefully) want to introduce this sollution to support multisite installation, this is the way I overcame the problem:

    The trick is to use the map_meta_cap filter to turn turn the do_not_allow capability in the $caps array into either edit_users, delete_users og create_users.

    The following function did the trick for me:

    function mc_admin_users_caps( $caps, $cap, $user_id, $args ){
    
    	foreach( $caps as $key => $capability ){
    
    		if( $capability != 'do_not_allow' )
    			continue;
    
    		switch( $cap ) {
    			case 'edit_user':
    			case 'edit_users':
    				$caps[$key] = 'edit_users';
    				break;
    			case 'delete_user':
    			case 'delete_users':
    				$caps[$key] = 'delete_users';
    				break;
    			case 'create_users':
    				$caps[$key] = $cap;
    				break;
    		}
    	}
    
    	return $caps;
    }
    add_filter( 'map_meta_cap', 'mc_admin_users_caps', 1, 4 );
    remove_all_filters( 'enable_edit_any_user_configuration' );
    add_filter( 'enable_edit_any_user_configuration', '__return_true');
    
    /**
     * Checks that both the editing user and the user being edited are
     * members of the blog and prevents the super admin being edited.
     */
    function mc_edit_permission_check() {
    	global $current_user, $profileuser;
    
    	$screen = get_current_screen();
    
    	get_currentuserinfo();
    
    	if( $screen->base == 'user-edit' || $screen->base == 'user-edit-network' ) { // editing a user profile
    		if ( ! is_super_admin( $current_user->ID ) && is_super_admin( $profileuser->ID ) ) { // trying to edit a superadmin while less than a superadmin
    			wp_die( __( 'You do not have permission to edit this user.' ) );
    		} elseif ( ! ( is_user_member_of_blog( $profileuser->ID, get_current_blog_id() ) && is_user_member_of_blog( $current_user->ID, get_current_blog_id() ) )) { // editing user and edited user aren't members of the same blog
    			wp_die( __( 'You do not have permission to edit this user.' ) );
    		}
    	}
    
    }
    add_filter( 'admin_head', 'mc_edit_permission_check', 1, 4 );
  5. Chris Montgomery
    Member
    Posted 1 year ago #

    Thanks Sjobidoo — I was having the same problem on my multisite install and this fixed the issue for me too.

  6. elanio
    Member
    Posted 1 year ago #

    Sjobidoo, thanks for this, and sorry I am late to the party. May I ask what file you put this function, and where? I am experiencing the same issue.

  7. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    There is functions.php file at your active theme folder. You may put this stuff there.

  8. elanio
    Member
    Posted 1 year ago #

    Thanks for the Reply Vladamir. I ended up choosing to put this into the plugin itself in the user-role-editor.php file. It makes it much easier to maintain in one place vs having to insert the functions into each theme.

    Do you plan to incorporate Sjobidoo fix in future releases, I am sure this is a much sought after addition.

    Much appreciated for all the excellent work you have done now, and will do!

  9. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for sharing your experience. I will add this code to the next version. It will work as an option. That is if someone need it, he will be able to turn this feature on by defining special constant in wp-config.php.

  10. elanio
    Member
    Posted 1 year ago #

    Wow, great responsiveness to the forums, and a truly great plugin. Keep at it, and looking forward to receiving the update!

  11. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    I have to skip this for upcoming v. 3.14 and postpone including this feature to the 3.15. It requires more accurate investigation for compatibility with other plugins, S2Member for example.

  12. elanio
    Member
    Posted 12 months ago #

    Was this fix put in for version 4.1.1?

  13. Vladimir Garagulya
    Member
    Plugin Author

    Posted 12 months ago #

    Ups! I missed this suggestion. So answer is negative.
    I will write it in to-do list just now :).
    Thanks for recalling me this.

  14. cwilliams89
    Member
    Posted 11 months ago #

    Really looking forward to a fix!

  15. Vladimir Garagulya
    Member
    Plugin Author

    Posted 11 months ago #

    Hi,

    It's almost ready. I make last tests and plan to publish version 4.2 this weekend. If you desire to help, you may download Beta version from this link:
    http://role-editor.com/downloads/user-role-editor-4.2-beta.zip
    You need to turn on checkbox at the Settings page in order activate 'edit users for non-super-admin' option.

    Thanks in advance for sharing the results.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.