WordPress.org

Make WordPress Core

Ticket #9422: 9422-user-delete-transaction.diff

File 9422-user-delete-transaction.diff, 1.0 KB (added by Denis-de-Bernardy, 5 years ago)

wrap wp_delete_user into hooks to allow for being/commit sql statements

  • Users/denis/Sites/wp/wp-admin/includes/user.php

     
    411411        global $wpdb; 
    412412 
    413413        $id = (int) $id; 
     414         
     415        // allow for transaction statement 
     416        do_action('delete_user', $id); 
    414417 
    415418        if ($reassign == 'novalue') { 
    416419                $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) ); 
     
    429432        } 
    430433 
    431434        // FINALLY, delete user 
    432         do_action('delete_user', $id); 
    433435 
    434436        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) ); 
    435437        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) ); 
     
    439441        wp_cache_delete($id, 'users'); 
    440442        wp_cache_delete($user->user_login, 'userlogins'); 
    441443        wp_cache_delete($user->user_email, 'useremail'); 
     444         
     445        // allow for commit transaction 
     446        do_action('deleted_user', $id); 
    442447 
    443448        return true; 
    444449}