From 5e53ed70d857cbad4cebb76fbea952b201e6935a Mon Sep 17 00:00:00 2001 From: Jaume Date: Sat, 22 Apr 2017 20:06:56 +0200 Subject: [PATCH] Fix: Creating customer triggers password changed Sending POST /wc/v1/customers or POST /wc/v2/customers with the required args triggers the 'Notice of Password Changed' after creating the customer due to update() calls when the password still has a value. --- includes/data-stores/class-wc-customer-data-store.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/data-stores/class-wc-customer-data-store.php b/includes/data-stores/class-wc-customer-data-store.php index cc5f8913e8b..652d529f69d 100644 --- a/includes/data-stores/class-wc-customer-data-store.php +++ b/includes/data-stores/class-wc-customer-data-store.php @@ -101,6 +101,10 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat $customer->set_id( $id ); $this->update_user_meta( $customer ); + + // Prevent wp_update_user calls in the same request and customer trigger the 'Notice of Password Changed' email + $customer->set_password( '' ); + wp_update_user( apply_filters( 'woocommerce_update_customer_args', array( 'ID' => $customer->get_id(), 'role' => $customer->get_role(),