Reply To: User getting “customer new account” email even if disabled

Home Forums Email Verification for WooCommerce User getting “customer new account” email even if disabled Reply To: User getting “customer new account” email even if disabled

#107010
Andrea Baron
Participant

Hi Moshtafizur,

I found the problem. It comes from a change introduced in version 2.4.3 of the plugin.
In file includes/class-alg-wc-ev-emails.php on line 410 the function maybe_disable_customer_new_account_email does this:
function maybe_disable_customer_new_account_email( $enable ) {
$enable = $this->activate_customer_new_account_email;
return $enable;
}
and completely ignores what comes from the $enable argument. So if the email is disabled from WooCommerce, and your plugin wants it enabled (it happens through the enable_customer_new_account_email function when the woocommerce_created_customer_notification hook is called) the new_account email becomes enabled anyway.

The function should be written like this:
function maybe_disable_customer_new_account_email( $enable ) {
return $enable && $this->activate_customer_new_account_email;
}
now, if the user wants the email enabled ($enabled is true) and also the plugin ($this->activate_customer_new_account_email is true) then the mail gets sent but not in the other cases, so the user preference is now honoured.

I hope you can release an update soon.

Thanks!