Menu Close

WooCommerce: Disable “Password Changed” Administrator Emails

default

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!

Here’s the not-very-helpful email that WooCommerce/WordPress admins get when a user resets their password. If you wish to get rid of them, use the 1-liner below!

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
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_disable_password_change_notification', '__return_true' );
View Source
Posted in WooCommerce Tips