Make WordPress Core

Ticket #16358: 16358-no-nav_menu_item.diff

File 16358-no-nav_menu_item.diff, 860 bytes (added by nacin, 15 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_not_delete = apply_filters( 'delete_user_not_these_post_types', array( 'nav_menu_item' ), $id );
     282                $post_types = array_diff( get_post_types(), $post_types_to_not_delete );
     283                $post_types = implode( "', '", $post_types );
     284                $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types')", $id) );
    282285
    283286                if ( $post_ids ) {
    284287                        foreach ( $post_ids as $post_id )