Make WordPress Core

Ticket #16358: 16358-post_type_supports.diff

File 16358-post_type_supports.diff, 909 bytes (added by nacin, 13 years ago)
  • wp-admin/includes/user.php

     
    278278        do_action('delete_user', $id);
    279279
    280280        if ( 'novalue' === $reassign || null === $reassign ) {
    281                 $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) );
     281                $post_types_to_delete = array( 'attachment', 'revision' );
     282                foreach ( get_post_types() as $post_type ) {
     283                        if ( post_type_supports( $post_type, 'author' )
     284                                $post_types_to_delete[] = $post_type;
     285                }
     286                $post_types_to_delete = implode( "', '", $post_types_to_delete );
     287                $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id) );
    282288
    283289                if ( $post_ids ) {
    284290                        foreach ( $post_ids as $post_id )