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. git-svn-id: https://develop.svn.wordpress.org/trunk@45806 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9c3fb72719
commit
a636529b7c
@ -234,6 +234,11 @@ switch ( $wp_list_table->current_action() ) {
|
|||||||
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
|
$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
|
* Filters whether the users being deleted have additional content
|
||||||
* associated with them outside of the `post_author` and `link_owner` relationships.
|
* 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 );
|
$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' ) ) {
|
if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
|
||||||
$users_have_content = true;
|
$users_have_content = true;
|
||||||
} elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
|
} 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() ) {
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ( 1 == count( $userids ) ) : ?>
|
<?php if ( 1 == count( $all_userids ) ) : ?>
|
||||||
<p><?php _e( 'You have specified this user for deletion:' ); ?></p>
|
<p><?php _e( 'You have specified this user for deletion:' ); ?></p>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<p><?php _e( 'You have specified these users for deletion:' ); ?></p>
|
<p><?php _e( 'You have specified these users for deletion:' ); ?></p>
|
||||||
@ -280,7 +285,7 @@ switch ( $wp_list_table->current_action() ) {
|
|||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
$go_delete = 0;
|
$go_delete = 0;
|
||||||
foreach ( $userids as $id ) {
|
foreach ( $all_userids as $id ) {
|
||||||
$user = get_userdata( $id );
|
$user = get_userdata( $id );
|
||||||
if ( $id == $current_user->ID ) {
|
if ( $id == $current_user->ID ) {
|
||||||
/* translators: 1: user id, 2: user login */
|
/* translators: 1: user id, 2: user login */
|
||||||
@ -314,7 +319,7 @@ switch ( $wp_list_table->current_action() ) {
|
|||||||
wp_dropdown_users(
|
wp_dropdown_users(
|
||||||
array(
|
array(
|
||||||
'name' => 'reassign_user',
|
'name' => 'reassign_user',
|
||||||
'exclude' => array_diff( $userids, array( $current_user->ID ) ),
|
'exclude' => $userids,
|
||||||
'show' => 'display_name_with_login',
|
'show' => 'display_name_with_login',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user