Changeset 2704 for trunk/wp-admin/admin-functions.php
- Timestamp:
- 07/12/2005 03:53:13 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/admin-functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r2702 r2704 302 302 } 303 303 304 function wp_delete_user($id ) {304 function wp_delete_user($id, $reassign = 'novalue') { 305 305 global $wpdb; 306 306 307 307 $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 320 325 // Clean links 321 326 $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}"); 324 331 } 325 332
Note: See TracChangeset
for help on using the changeset viewer.