WordPress.org

Make WordPress Core

Ticket #19500: 19500.diff

File 19500.diff, 1.4 KB (added by nacin, 6 years ago)
  • wp-includes/user.php

     
    716716                }
    717717        }
    718718
     719        if ( ! $blogs ) // No blogs means false.
     720                $blogs = false;
     721
    719722        return apply_filters( 'get_blogs_of_user', $blogs, $user_id, $all );
    720723}
    721724
  • wp-admin/includes/user.php

     
    291291        clean_user_cache($id);
    292292
    293293        // FINALLY, delete user
    294         if ( !is_multisite() ) {
    295                 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
    296                 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
     294        if ( is_multisite() ) {
     295                remove_user_from_blog( $user_id, get_current_blog_id() );
    297296        } else {
    298                 $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
    299                 $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$level_key}'");
     297                $meta = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->usermeta WHERE user_id = %d", %id ) );
     298                foreach ( $meta as $mid )
     299                        delete_metadata_by_mid( 'user', $mid );
     300                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id ) );
    300301        }
    301302
    302303        // allow for commit transaction