From 63ceacb67a09cdd67383c5b8511c08738bee6605 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sat, 7 Mar 2015 04:40:28 +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. Built from https://develop.svn.wordpress.org/trunk@31656 git-svn-id: http://core.svn.wordpress.org/trunk@31637 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/network/users.php | 62 +++++++++++++++++++++++++++----------- wp-includes/version.php | 2 +- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/wp-admin/network/users.php b/wp-admin/network/users.php index 7cfdf190c2..650c3ca089 100644 --- a/wp-admin/network/users.php +++ b/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 ) : ?> +

+ +

+
diff --git a/wp-includes/version.php b/wp-includes/version.php index 5f6b218e0a..a552c7ae93 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31655'; +$wp_version = '4.2-alpha-31656'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.