I can't give admins the ability to edit users for a subsite

I have a client site and he needs to be able to edit user info. I made him an admin but he still can't click on users. Any thoughts? I am probably missing something easy.

I gave all rights with role manager and still it doesn't allow it.

Thanks

  • Vaughan

    Hi Max,

    This is an actual design in the WP core apparently, on a multisite only super admins can edit user details.

    You can try adding the following to a mu-plugin

    Create a file called wpmu-admin-edit-users.php

    Then add the following to this file

    <?php
    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( ! is_super_admin( $current_user->ID ) && in_array( $screen->base, array( 'user-edit', 'user-edit-network' ) ) ) { // editing a user profile
            if ( 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 );

    Now upload this file to /wp-content/mu-plugins/

    If mu-plugins doesn't exist, just create it.

    I haven't tested this personally, it's from an old article posted here, but recent comments on it suggest it should still work.

    http://thereforei.am/2011/03/15/how-to-allow-administrators-to-edit-users-in-a-wordpress-network/

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.