From f0b524dad051cbff57df97c74771e09536cb24c6 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sat, 7 Mar 2015 04:39:13 +0000 Subject: [PATCH] Improve experience when deleting users from a multisite network. When deleting a user who is not associated with any sites, the current messaging can be confusing as only users associated with at least one site actually appear on the confirmation page for deletion. This experience can be improved by showing all users being deleted as well as their current site associations. * If an empty array of users is passed, don't attempt to confirm deletion. * If one user is passed, show a message crafted for a user of one. * If multiple users are passed, show a message crafted for many. * Show the pending results of all users to be deleted. * Update messaging around the deletion/confirmation process to be less misleading. Props Idealien, HarishChaudhari, DrewAPicture. Fixes #18132. git-svn-id: https://develop.svn.wordpress.org/trunk@31656 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/network/users.php | 62 ++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/src/wp-admin/network/users.php b/src/wp-admin/network/users.php index 7cfdf190c2..650c3ca089 100644 --- a/src/wp-admin/network/users.php +++ b/src/wp-admin/network/users.php @@ -18,34 +18,46 @@ if ( ! current_user_can( 'manage_network_users' ) ) function confirm_delete_users( $users ) { $current_user = wp_get_current_user(); - if ( !is_array( $users ) ) + if ( ! is_array( $users ) || empty( $users ) ) { return false; + } ?>

-

+ + 1 ) : ?> +

+ +

+ +
ID . '">' . $current_user->user_login . ''; - - foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) { + $admin_out = ''; ?> + + ID ) ) + if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) { wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) ); + } - if ( in_array( $delete_user->user_login, $site_admins ) ) - wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), $delete_user->user_login ) ); + if ( in_array( $delete_user->user_login, $site_admins ) ) { + wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '' . $delete_user->user_login . '' ) ); + } + ?> + + + \n"; - $blogs = get_blogs_of_user( $user_id, true ); - - if ( !empty( $blogs ) ) { + if ( ! empty( $blogs ) ) { ?> -

' . $delete_user->user_login . '' ); ?>

+
"; + } else { + ?> + + +
user_login; ?> + ' . "\n"; ?> +

' . $delete_user->user_login . '' ); ?>

$details ) { $blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) ); @@ -55,11 +67,13 @@ function confirm_delete_users( $users ) { $user_dropdown .= "\n"; ?> @@ -73,14 +87,28 @@ function confirm_delete_users( $users ) { "; - } + echo "

+ +
+ 1 ) : ?> +

+ +

+