Make WordPress Core


Ignore:
Timestamp:
04/14/2004 06:00:16 PM (21 years ago)
Author:
saxmatt
Message:

When I say delete, I really mean it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/users.php

    r957 r1070  
    131131    require_once('admin-header.php');
    132132
    133     $id = $HTTP_GET_VARS['id'];
     133    $id = intval($HTTP_GET_VARS['id']);
    134134
    135135    if (!$id) {
     
    143143        die('Can’t delete a user whose level is higher than yours.');
    144144
    145     $sql = "DELETE FROM $tableusers WHERE ID = $id";
    146     $result = $wpdb->query($sql) or die("Couldn’t delete user #$id.");
    147 
    148     $sql = "DELETE FROM $tableposts WHERE post_author = $id";
    149     $result = $wpdb->query($sql) or die("Couldn’t delete user #$id’s posts.");
    150 
    151     header('Location: users.php');
     145    $post_ids = $wpdb->get_col("SELECT ID FROM $tableposts WHERE post_author = $id");
     146    $post_ids = implode(',', $post_ids);
     147   
     148    // Delete comments, *backs
     149    $wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID IN ($post_ids)");
     150    // Clean cats
     151    $wpdb->query("DELETE FROM $tablepost2cat WHERE post_id IN ($post_ids)");
     152    // Clean post_meta
     153    $wpdb->query("DELETE FROM $tablepostmeta WHERE post_id IN ($post_ids)");
     154    // Clean links
     155    $wpdb->query("DELETE FROM $tablelinks WHERE link_owner = $id");
     156    // Delete posts
     157    $wpdb->query("DELETE FROM $tableposts WHERE post_author = $id");
     158    // FINALLY, delete user
     159    $wpdb->query("DELETE FROM $tableusers WHERE ID = $id");
     160   
     161    header('Location: users.php?deleted=true');
    152162
    153163break;
     
    158168    include ('admin-header.php');
    159169    ?>
     170<?php if ($_GET['deleted']) : ?>
     171<div class="updated"><p>User deleted.</p></div>
     172<?php endif; ?>
    160173<div class="wrap">
    161174  <h2>Authors</h2>
Note: See TracChangeset for help on using the changeset viewer.