I just gave single-site administrators the right to add brand new users by adding the following code to my custom plugin that deals with user roles:

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

Now, when my admin logs in, they can add new users the way I want them to, but I don’t want to give them the option to add an existing user. I attached a screenshot to help you see what I’m talking about. Any idea of how I can keep the ability for admins to add new users, but not existing ones?

Read more here: How to remove option to "Add Existing User" for WP multisite admins?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: