The “Password Changed” email is – actually – a WordPress core notification. It goes to admins when a WordPress user changes their password, and the email body says something along the lines of “Password changed for user: XYZ“.
So, why are we saying this email notification can be stopped if you run a WooCommerce website? Well, because WooCommerce provides us developers with a handy filter, that we can use for this exact reason.
For what concerns my own experience, I use Sendgrid to deliver Business Bloomer WordPress/WooCommerce emails – and on the free plan I have a limit of 100 daily emails. Which means I needed to find a way to reduce the number of email notifications.
Today we’ll cover the “Password Changed” one – let’s see how to stop administrators from getting them!
PHP Snippet: Disable “Password Changed” Admin Email Notification (WordPress)
The WooCommerce plugin comes with this handy function, which triggers on the My Account page:
/**
* Handles resetting the user's password.
*
* @param object $user The user.
* @param string $new_pass New password for the user in plaintext.
*/
public static function reset_password( $user, $new_pass ) {
do_action( 'password_reset', $user, $new_pass );
wp_set_password( $new_pass, $user->ID );
self::set_reset_password_cookie();
if ( ! apply_filters( 'woocommerce_disable_password_change_notification', false ) ) {
wp_password_change_notification( $user );
}
}
This means we can use the ‘woocommerce_disable_password_change_notification‘ filter if we wish to disable the Password Changed emails:
/**
* @snippet Disable "Password Changed" Admin Emails
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 8
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_disable_password_change_notification', '__return_true' );
Has anyone reported this doesn’t work? I added it to my functions.php but the emails are still being sent.
Hi Shelley, just checked and Woo still comes with this filter, so my code still works. It must be something else
We encountered an error activating your snippet, please check the syntax and try again. Error message: syntax error, unexpected token public, expecting end of file
This is not working. Showing errors.
Hello Pritam! You only need to paste the add_filter line, and not the previous function that is only there togive some context. Can you please let me know?