Merge pull request #25489 from woocommerce/fix/25338

Check if wp_delete_user() exists before use
This commit is contained in:
Rodrigo Primo 2020-01-28 17:34:30 -03:00 committed by GitHub
commit 151984a9cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -344,7 +344,7 @@ class WC_Privacy extends WC_Abstract_Privacy {
'Subscriber',
)
),
'meta_query' => array(
'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'relation' => 'AND',
array(
'key' => 'wc_last_active',
@ -365,6 +365,10 @@ class WC_Privacy extends WC_Abstract_Privacy {
$user_ids = $user_query->get_results();
if ( $user_ids ) {
if ( ! function_exists( 'wp_delete_user' ) ) {
require_once ABSPATH . 'wp-admin/includes/user.php';
}
foreach ( $user_ids as $user_id ) {
wp_delete_user( $user_id );
$count ++;