Skip to:
Content

bbPress.org

Changeset 5429


Ignore:
Timestamp:
07/08/2014 02:11:54 AM (11 years ago)
Author:
netweb
Message:

When resetting the forums back to pre-import status, if we are not deleting imported users, we still need to delete existing user meta-data.

  • r5174 originally implemented this as if/else, antiprops netweb

Fixes #2641. Props netweb

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/tools.php

    r5401 r5429  
    642642        return array( 1, sprintf( $statement, $result ) );
    643643    }
    644  
     644
    645645    // Recalculate the metas key _bbp_reply_count and _bbp_total_reply_count for each forum
    646646    $forums = get_posts( array( 'post_type' => bbp_get_forum_post_type(), 'numberposts' => -1 ) );
     
    13251325    // Delete cases where `_bbp_reply_to` was accidentally set to itself
    13261326    if ( is_wp_error( $wpdb->query( "DELETE FROM `{$wpdb->postmeta}` WHERE `meta_key` = '_bbp_reply_to' AND `post_id` = `meta_value`;" ) ) ) {
    1327         return array( 1, sprintf( $statement, $result ) ); 
     1327        return array( 1, sprintf( $statement, $result ) );
    13281328    }
    13291329
     
    15011501    /** User ******************************************************************/
    15021502
    1503     // Delete users
     1503    // First, if we're deleting previously imported users, delete them now
    15041504    if ( !empty( $_POST['bbpress-delete-imported-users'] ) ) {
    15051505        $sql_users  = $wpdb->get_results( "SELECT `user_id` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '_bbp_user_id'", OBJECT_K );
     
    15191519            $messages[] = sprintf( $statement, $result );
    15201520        }
    1521 
    1522     // Delete imported user metadata
    1523     } else {
    1524         $statement  = __( 'Deleting User Meta… %s', 'bbpress' );
    1525         $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%';";
    1526         $result     = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success;
    1527         $messages[] = sprintf( $statement, $result );
    1528     }
     1521    }
     1522
     1523    // Next, if we still have users that were not imported delete that meta data
     1524    $statement  = __( 'Deleting User Meta… %s', 'bbpress' );
     1525    $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%';";
     1526    $result     = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success;
     1527    $messages[] = sprintf( $statement, $result );
    15291528
    15301529    /** Converter *************************************************************/
Note: See TracChangeset for help on using the changeset viewer.