Make WordPress Core


Ignore:
Timestamp:
07/12/2005 03:53:13 PM (21 years ago)
Author:
ryan
Message:

Roles update + UI from Owen.

File:
1 edited

Legend:

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

    r2702 r2704  
    302302}
    303303
    304 function wp_delete_user($id) {
     304function wp_delete_user($id, $reassign = 'novalue') {
    305305    global $wpdb;
    306306
    307307    $id = (int) $id;
    308 
    309     $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
    310 
    311     if ($post_ids) {
    312         $post_ids = implode(',', $post_ids);
    313        
    314         // Delete comments, *backs
    315         $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
    316         // Clean cats
    317         $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
    318         // Clean post_meta
    319         $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
     308   
     309    if($reassign == 'novalue') {
     310        $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
     311   
     312        if ($post_ids) {
     313            $post_ids = implode(',', $post_ids);
     314           
     315            // Delete comments, *backs
     316            $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
     317            // Clean cats
     318            $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
     319            // Clean post_meta
     320            $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
     321            // Delete posts
     322            $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
     323        }
     324   
    320325        // Clean links
    321326        $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
    322         // Delete posts
    323         $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
     327    } else {
     328        $reassign = (int)$reassign;
     329        $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}");
     330        $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}");
    324331    }
    325332
Note: See TracChangeset for help on using the changeset viewer.