Skip to:
Content

bbPress.org

Changeset 5173


Ignore:
Timestamp:
11/23/2013 12:35:50 PM (11 years ago)
Author:
johnjamesjacoby
Message:

When resetting the forums back to pre-import status, allow admins to delete imported users. This handles the clean up of a potentially botched import, while also helping revert a site back to a pre-bbPress configuration. Fixes #1889. Props netweb.

File:
1 edited

Legend:

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

    r5157 r5173  
    11521152                    </tr>
    11531153                    <tr valign="top">
    1154                         <th scope="row"><?php esc_html_e( 'Are you sure you want to do this?', 'bbpress' ) ?></th>
     1154                        <th scope="row"><?php esc_html_e( 'Delete imported users?', 'bbpress' ); ?></th>
    11551155                        <td>
    11561156                            <fieldset>
    1157                                 <legend class="screen-reader-text"><span><?php esc_html_e( "Say it ain't so!", 'bbpress' ) ?></span></legend>
     1157                                <legend class="screen-reader-text"><span><?php esc_html_e( "Say it ain't so!", 'bbpress' ); ?></span></legend>
     1158                                <label><input type="checkbox" class="checkbox" name="bbpress-delete-imported-users" id="bbpress-delete-imported-users" value="1" /> <?php esc_html_e( 'This option will delete all previously imported users, and cannot be undone.', 'bbpress' ); ?></label>
     1159                            </fieldset>
     1160                        </td>
     1161                    </tr>
     1162                    <tr valign="top">
     1163                        <th scope="row"><?php esc_html_e( 'Are you sure you want to do this?', 'bbpress' ); ?></th>
     1164                        <td>
     1165                            <fieldset>
     1166                                <legend class="screen-reader-text"><span><?php esc_html_e( "Say it ain't so!", 'bbpress' ); ?></span></legend>
    11581167                                <label><input type="checkbox" class="checkbox" name="bbpress-are-you-sure" id="bbpress-are-you-sure" value="1" /> <?php esc_html_e( 'This process cannot be undone.', 'bbpress' ); ?></label>
    11591168                            </fieldset>
     
    12031212    wp_cache_flush();
    12041213
    1205     /** Posts *************************************************************/
     1214    /** Posts *****************************************************************/
    12061215
    12071216    $statement  = __( 'Deleting Posts&hellip; %s', 'bbpress' );
     
    12111220    $messages[] = sprintf( $statement, $result );
    12121221
    1213 
    1214     /** Post Meta *********************************************************/
     1222    /** Post Meta *************************************************************/
    12151223
    12161224    if ( !empty( $sql_posts ) ) {
     1225        $sql_meta = array();
    12171226        foreach ( $sql_posts as $key => $value ) {
    12181227            $sql_meta[] = $key;
     
    12251234    }
    12261235
    1227     /** Topic Tags ********************************************************/
     1236    /** Topic Tags ************************************************************/
    12281237
    12291238    $statement  = __( 'Deleting Topic Tags&hellip; %s', 'bbpress' );
     
    12321241    $messages[] = sprintf( $statement, $result );
    12331242
    1234     /** User Meta *********************************************************/
    1235 
    1236     $statement  = __( 'Deleting User Meta&hellip; %s', 'bbpress' );
    1237     $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%';";
    1238     $result     = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success;
    1239     $messages[] = sprintf( $statement, $result );
    1240 
    1241     /** Converter *********************************************************/
     1243    /** User ******************************************************************/
     1244
     1245    if ( !empty( $_POST['bbpress-delete-imported-users'] ) ) {
     1246        $sql_users  = $wpdb->get_results( "SELECT `user_id` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '_bbp_user_id'", OBJECT_K );
     1247        if ( !empty( $sql_users ) ) {
     1248            $sql_meta = array();
     1249            foreach ( $sql_users as $key => $value ) {
     1250                $sql_meta[] = $key;
     1251            }
     1252            $statement  = __( 'Deleting User&hellip; %s', 'bbpress' );
     1253            $sql_meta   = implode( "', '", $sql_meta );
     1254            $sql_delete = "DELETE FROM `{$wpdb->users}` WHERE `ID` IN ('{$sql_meta}');";
     1255            $result     = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success;
     1256            $messages[] = sprintf( $statement, $result );
     1257            $statement  = __( 'Deleting User Meta&hellip; %s', 'bbpress' );
     1258            $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `user_id` IN ('{$sql_meta}');";
     1259            $result     = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success;
     1260            $messages[] = sprintf( $statement, $result );
     1261        }
     1262    }
     1263
     1264    /** Converter *************************************************************/
    12421265
    12431266    $statement  = __( 'Deleting Conversion Table&hellip; %s', 'bbpress' );
     
    12511274    $messages[] = sprintf( $statement, $result );
    12521275
    1253     /** Options ***********************************************************/
     1276    /** Options ***************************************************************/
    12541277
    12551278    $statement  = __( 'Deleting Settings&hellip; %s', 'bbpress' );
     
    12571280    $messages[] = sprintf( $statement, $success );
    12581281
    1259     /** Roles *************************************************************/
     1282    /** Roles *****************************************************************/
    12601283
    12611284    $statement  = __( 'Deleting Roles and Capabilities&hellip; %s', 'bbpress' );
     
    12651288    $messages[] = sprintf( $statement, $success );
    12661289
    1267     /** Output ************************************************************/
     1290    /** Output ****************************************************************/
    12681291
    12691292    if ( count( $messages ) ) {
Note: See TracChangeset for help on using the changeset viewer.