When I say delete, I really mean it.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1070 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-04-14 18:00:16 +00:00
parent c9d60045bb
commit 3cd2ef14b4
1 changed files with 21 additions and 8 deletions

View File

@ -130,7 +130,7 @@ case 'delete':
$standalone = 1; $standalone = 1;
require_once('admin-header.php'); require_once('admin-header.php');
$id = $HTTP_GET_VARS['id']; $id = intval($HTTP_GET_VARS['id']);
if (!$id) { if (!$id) {
header('Location: users.php'); header('Location: users.php');
@ -142,13 +142,23 @@ case 'delete':
if ($user_level <= $usertodelete_level) if ($user_level <= $usertodelete_level)
die('Can&#8217;t delete a user whose level is higher than yours.'); die('Can&#8217;t delete a user whose level is higher than yours.');
$sql = "DELETE FROM $tableusers WHERE ID = $id"; $post_ids = $wpdb->get_col("SELECT ID FROM $tableposts WHERE post_author = $id");
$result = $wpdb->query($sql) or die("Couldn&#8217;t delete user #$id."); $post_ids = implode(',', $post_ids);
$sql = "DELETE FROM $tableposts WHERE post_author = $id"; // Delete comments, *backs
$result = $wpdb->query($sql) or die("Couldn&#8217;t delete user #$id&#8217;s posts."); $wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID IN ($post_ids)");
// Clean cats
header('Location: users.php'); $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');
break; break;
@ -157,6 +167,9 @@ default:
$standalone = 0; $standalone = 0;
include ('admin-header.php'); include ('admin-header.php');
?> ?>
<?php if ($_GET['deleted']) : ?>
<div class="updated"><p>User deleted.</p></div>
<?php endif; ?>
<div class="wrap"> <div class="wrap">
<h2>Authors</h2> <h2>Authors</h2>
<table cellpadding="3" cellspacing="3" width="100%"> <table cellpadding="3" cellspacing="3" width="100%">