From ec7fa69ef43ba501851b5ca1ab8a8e6f14f4bd8e Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 23 Dec 2015 04:45:42 +0000 Subject: [PATCH] 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. Props swissspidy & tharsheblows for initial patches. Fixes #34993 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@36068 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/users.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php index 44d860ecfa..e02c3943e8 100644 --- a/src/wp-admin/users.php +++ b/src/wp-admin/users.php @@ -211,13 +211,14 @@ case 'delete': else $userids = array_map( 'intval', (array) $_REQUEST['users'] ); - $users_posts = new WP_Query( array( - 'post_type' => 'any', - 'author' => implode( ',', $userids ), - 'posts_per_page' => 1 - ) ); + $users_have_content = false; + 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" ) ) { + $users_have_content = true; + } - if ( $users_posts->have_posts() ) { + if ( $users_have_content ) { add_action( 'admin_head', 'delete_users_add_js' ); } @@ -257,7 +258,7 @@ case 'delete': have_posts() ) : ?> + if ( ! $users_have_content ) : ?>