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
This commit is contained in:
parent
83f93e5e70
commit
ec7fa69ef4
@ -211,13 +211,14 @@ case 'delete':
|
|||||||
else
|
else
|
||||||
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
|
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
|
||||||
|
|
||||||
$users_posts = new WP_Query( array(
|
$users_have_content = false;
|
||||||
'post_type' => 'any',
|
if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) {
|
||||||
'author' => implode( ',', $userids ),
|
$users_have_content = true;
|
||||||
'posts_per_page' => 1
|
} 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' );
|
add_action( 'admin_head', 'delete_users_add_js' );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +258,7 @@ case 'delete':
|
|||||||
</ul>
|
</ul>
|
||||||
<?php if ( $go_delete ) :
|
<?php if ( $go_delete ) :
|
||||||
|
|
||||||
if ( ! $users_posts->have_posts() ) : ?>
|
if ( ! $users_have_content ) : ?>
|
||||||
<input type="hidden" name="delete_option" value="delete" />
|
<input type="hidden" name="delete_option" value="delete" />
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php if ( 1 == $go_delete ) : ?>
|
<?php if ( 1 == $go_delete ) : ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user