Don't delete everything if there are no posts.

git-svn-id: https://develop.svn.wordpress.org/trunk@1207 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2004-04-28 20:36:31 +00:00
parent 2608fbf8a9
commit 6c021cac79
1 changed files with 16 additions and 15 deletions

View File

@ -138,21 +138,22 @@ case 'delete':
die(__('Can’t delete a user whose level is higher than yours.')); die(__('Can’t delete a user whose level is higher than yours.'));
$post_ids = $wpdb->get_col("SELECT ID FROM $tableposts WHERE post_author = $id"); $post_ids = $wpdb->get_col("SELECT ID FROM $tableposts WHERE post_author = $id");
$post_ids = implode(',', $post_ids); if ($post_ids) {
$post_ids = implode(',', $post_ids);
// Delete comments, *backs
$wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID IN ($post_ids)");
// Clean cats
$wpdb->query("DELETE FROM $tablepost2cat WHERE post_id IN ($post_ids)");
// Clean post_meta
$wpdb->query("DELETE FROM $tablepostmeta WHERE post_id IN ($post_ids)");
// Clean links
$wpdb->query("DELETE FROM $tablelinks WHERE link_owner = $id");
// Delete posts
$wpdb->query("DELETE FROM $tableposts WHERE post_author = $id");
// FINALLY, delete user
$wpdb->query("DELETE FROM $tableusers WHERE ID = $id");
// Delete comments, *backs
$wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID IN ($post_ids)");
// Clean cats
$wpdb->query("DELETE FROM $tablepost2cat WHERE post_id IN ($post_ids)");
// Clean post_meta
$wpdb->query("DELETE FROM $tablepostmeta WHERE post_id IN ($post_ids)");
// Clean links
$wpdb->query("DELETE FROM $tablelinks WHERE link_owner = $id");
// Delete posts
$wpdb->query("DELETE FROM $tableposts WHERE post_author = $id");
// FINALLY, delete user
$wpdb->query("DELETE FROM $tableusers WHERE ID = $id");
}
header('Location: users.php?deleted=true'); header('Location: users.php?deleted=true');
break; break;