From 6714658fbc67986478ea8677e75582ee581c98ed Mon Sep 17 00:00:00 2001 From: Shiva Poudel Date: Fri, 23 Feb 2018 10:17:21 +0545 Subject: [PATCH] Delete all usermeta on uninstall with prefix woocommerce_ --- uninstall.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/uninstall.php b/uninstall.php index 6cb360ea68c..62010969dec 100644 --- a/uninstall.php +++ b/uninstall.php @@ -51,17 +51,15 @@ if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) { // Delete options. $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce\_%';" ); + // Delete usermeta. + $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'woocommerce\_%';" ); + // Delete posts + data. $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation', 'shop_coupon', 'shop_order', 'shop_order_refund' );" ); $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_order_items" ); $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_order_itemmeta" ); - // Delete user meta data. - foreach ( array( 'woocommerce_keys_per_page', 'woocommerce_webhooks_per_page' ) as $meta_key ) { - delete_metadata( 'user', 0, $meta_key, '', true ); - } - // Delete terms if > WP 4.2 (term splitting was added in 4.2). if ( version_compare( $wp_version, '4.2', '>=' ) ) { // Delete term taxonomies.