From ab0b860db9662b9fae1abe8ba4588da0a6f84a4e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 15 Aug 2019 13:06:55 +0000 Subject: [PATCH] Users: When deleting users, exclude the current user from the content existence check. The current user cannot be deleted, so the check is redundant in that context and should only be done for other users. Props mt8.biz, SergeyBiryukov. Fixes #47851. Built from https://develop.svn.wordpress.org/trunk@45806 git-svn-id: http://core.svn.wordpress.org/trunk@45617 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/users.php | 13 +++++++++---- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wp-admin/users.php b/wp-admin/users.php index 31f2bd9398..6ca1eb7af9 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -234,6 +234,11 @@ switch ( $wp_list_table->current_action() ) { $userids = array_map( 'intval', (array) $_REQUEST['users'] ); } + if ( in_array( $current_user->ID, $userids ) ) { + $all_userids = $userids; + $userids = array_diff( $userids, array( $current_user->ID ) ); + } + /** * Filters whether the users being deleted have additional content * associated with them outside of the `post_author` and `link_owner` relationships. @@ -245,7 +250,7 @@ switch ( $wp_list_table->current_action() ) { */ $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids ); - if ( ! $users_have_content ) { + if ( $userids && ! $users_have_content ) { if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { $users_have_content = true; } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { @@ -271,7 +276,7 @@ switch ( $wp_list_table->current_action() ) { - +

@@ -280,7 +285,7 @@ switch ( $wp_list_table->current_action() ) {