Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter Sjobidoo

    (@sjobidoo)

    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.

    Thread Starter Sjobidoo

    (@sjobidoo)

    Using a multisite installation.

    Any response from the developer on this issue would rock ??

    Thread Starter Sjobidoo

    (@sjobidoo)

    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 );

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

    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.

    Plugin Author Vladimir Garagulya

    (@shinephp)

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

    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!

    Plugin Author Vladimir Garagulya

    (@shinephp)

    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.

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

    Plugin Author Vladimir Garagulya

    (@shinephp)

    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.

    Was this fix put in for version 4.1.1?

    Plugin Author Vladimir Garagulya

    (@shinephp)

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

    Really looking forward to a fix!

    Plugin Author Vladimir Garagulya

    (@shinephp)

    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:
    https://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.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: User Role Editor] Not able to add ability to edit users’ is closed to new replies.