WordPress.org

Make WordPress Core

Changeset 10975


Ignore:
Timestamp:
04/17/09 02:13:00 (5 years ago)
Author:
ryan
Message:

Use API to delete links when deleting a user. Props TimButterfield, scohoust. fixes #7774

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/user.php

    r10894 r10975  
    412412 
    413413    $id = (int) $id; 
    414      
     414    $user = new WP_User($id);    
     415 
    415416    // allow for transaction statement 
    416417    do_action('delete_user', $id); 
     
    425426 
    426427        // Clean links 
    427         $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->links WHERE link_owner = %d", $id) ); 
     428        $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); 
     429 
     430        if ( $link_ids ) { 
     431            foreach ( $link_ids as $link_id ) 
     432                wp_delete_link($link_id); 
     433        } 
     434 
    428435    } else { 
    429436        $reassign = (int) $reassign; 
     
    436443    $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) ); 
    437444    $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) ); 
    438  
    439     $user = new WP_User($id); 
    440445 
    441446    wp_cache_delete($id, 'users'); 
Note: See TracChangeset for help on using the changeset viewer.