Make WordPress Core

Changeset 36106


Ignore:
Timestamp:
12/27/2015 02:16:40 AM (8 years ago)
Author:
dd32
Message:

Users: When determining whether to show the reassign content option during user delete, don't rely upon WP_Query as it doesn't return all forms of content wp_delete_user() operates on.

This restores the reassign form when a user has a non-public post type or links assigned to them.

Merges [36068] to the 4.4 branch.
Props swissspidy & tharsheblows for initial patches.
Fixes #34993.

Location:
branches/4.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

  • branches/4.4/src/wp-admin/users.php

    r35558 r36106  
    212212        $userids = array_map( 'intval', (array) $_REQUEST['users'] );
    213213
    214     $users_posts = new WP_Query( array(
    215         'post_type' => 'any',
    216         'author' => implode( ',', $userids ),
    217         'posts_per_page' => 1
    218     ) );
    219 
    220     if ( $users_posts->have_posts() ) {
     214    $users_have_content = false;
     215    if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) {
     216        $users_have_content = true;
     217    } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) {
     218        $users_have_content = true;
     219    }
     220
     221    if ( $users_have_content ) {
    221222        add_action( 'admin_head', 'delete_users_add_js' );
    222223    }
     
    258259<?php if ( $go_delete ) :
    259260
    260     if ( ! $users_posts->have_posts() ) : ?>
     261    if ( ! $users_have_content ) : ?>
    261262        <input type="hidden" name="delete_option" value="delete" />
    262263    <?php else: ?>
Note: See TracChangeset for help on using the changeset viewer.