WordPress.org

Make WordPress Core

Changeset 45806


Ignore:
Timestamp:
08/15/2019 01:05:39 PM (4 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/users.php

    r45674 r45806  
    235235        }
    236236
     237        if ( in_array( $current_user->ID, $userids ) ) {
     238            $all_userids = $userids;
     239            $userids     = array_diff( $userids, array( $current_user->ID ) );
     240        }
     241
    237242        /**
    238243         * Filters whether the users being deleted have additional content
     
    246251        $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids );
    247252
    248         if ( ! $users_have_content ) {
     253        if ( $userids && ! $users_have_content ) {
    249254            if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
    250255                $users_have_content = true;
     
    272277        <?php endif; ?>
    273278
    274         <?php if ( 1 == count( $userids ) ) : ?>
     279        <?php if ( 1 == count( $all_userids ) ) : ?>
    275280    <p><?php _e( 'You have specified this user for deletion:' ); ?></p>
    276281        <?php else : ?>
     
    281286        <?php
    282287        $go_delete = 0;
    283         foreach ( $userids as $id ) {
     288        foreach ( $all_userids as $id ) {
    284289            $user = get_userdata( $id );
    285290            if ( $id == $current_user->ID ) {
     
    315320                    array(
    316321                        'name'    => 'reassign_user',
    317                         'exclude' => array_diff( $userids, array( $current_user->ID ) ),
     322                        'exclude' => $userids,
    318323                        'show'    => 'display_name_with_login',
    319324                    )
Note: See TracChangeset for help on using the changeset viewer.