23

I want to disable the email notification if a user or an admin changes the password of a user.

After some Googling I came to find that I need to create a plugin and overwrite the wp_password_change_notification function found in pluggable.php.

This is the plugin and function:

<?php
/*
Plugin Name: Stop email change password
Description: Whatever
*/

if ( !function_exists( 'wp_password_change_notification' ) ) {
    function wp_password_change_notification() {}
}
?>

I uploaded the file to my plugin folder and activated it in my admin panel!

This needs to be done with a plugin because the pluggable.php file is loaded before the functions.php file.

Anyway it doesn't seem to work for me.

The user still receives the email.

I disabled all plugins and run the plugin on a clean install so no interference

The WP_DEBUG doesn't show any errors as well!

Can anybody tell me what to change or how to fix it any other way (except core modifications :-))

M.

1
  • 2
    I also struggled and tried creating/using a custom plugin, setting the WordPress-filters to false but nothing worked... Just today I stumbled upon the Manage Notification E-mails plugin and it works :)
    – Leander
    Commented Feb 26, 2016 at 9:40

10 Answers 10

36

To disable user email notification, add this in a plugin or theme:

add_filter( 'send_password_change_email', '__return_false' );

FYI wp_password_change_notification() controls admin email notification when a user changes their password

0
33

To disable Admin email notification when a user resets their own password, create a Plugin (or Must Use Plugin) using the following code snippet:

/**
 * Disable Admin Notification of User Password Change
 *
 * @see pluggable.php
 */
if ( ! function_exists( 'wp_password_change_notification' ) ) {
    function wp_password_change_notification( $user ) {
        return;
    }
}

This will stop the following email from being sent to the Administrator's Email in Settings > General:

From: WordPress <[email protected]>
To: [email protected]
Subject: [WordPress] Password Changed

Password changed for user: username

Suppressing this email notification has to handled with a plugin because pluggable.php is loaded earlier than a theme's functions.php file.


If you wish to instead disable User email notification that a user has successfully changed their own password, use the following filter placed in functions.php:

/**
 * Disable User Notification of Password Change Confirmation
 */
add_filter( 'send_password_change_email', '__return_false' );

This will suppress the following email from being sent:

From: WordPress <[email protected]>
To: [email protected]
Subject: [WordPress] Password Changed

Hi username,

This notice confirms that your password was changed on WordPress.

If you did not change your password, please contact the Site Administrator at [email protected]

This email has been sent to [email protected]

Regards,
All at WordPress
http://example.com/

3
  • 2
    There is a big mistake in this answer. The filter name is "send_password_change_email" not "send_email_change_email". codex.wordpress.org/Plugin_API/Filter_Reference/… Commented Apr 6, 2018 at 8:29
  • Noted. For reference, the two filters are related and can be used to disable user notification when an email or password is changed by the user. The use case for either depends on what notification you want to suppress — email change or password change. For a clear picture, refer to the WordPress function wp_update_user() in wp-includes/user.php: core.trac.wordpress.org/browser/tags/4.9.5/src/wp-includes/…
    – rjb
    Commented Apr 6, 2018 at 16:15
  • hi, why would a this wp_password_change_notification function will run when there is already same name function?
    – danny
    Commented Mar 13, 2023 at 20:05
3

If you're using Woocommerce:

Since WC 3.8.0 (November 2019), there is now a dedicated filter hook for this:

add_filter('woocommerce_disable_password_change_notification', '__return_true');

Should suppress password change notifications.

4
  • 2
    that hook is only for when using woocommerce (woocommerce 3.8, not wordpress 3.8)
    – Rafa
    Commented May 13, 2020 at 9:22
  • @Rafa Oops, yeah I have been doing so much WC + WP development that the lines have blurred for me. I've adjusted my answer thanks.
    – Mikepote
    Commented May 14, 2020 at 12:25
  • Beware that this will deactivate the user-facing password reset mail (see /woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php) and as such isn't related to the admin notifications...
    – Leander
    Commented Oct 4, 2022 at 18:35
  • This 'woocommerce_disable_password_change_notification' hook does indeed deactivate the admin "Password Changed" notification email that is triggered on WooCommerce sites. You'll notice in /woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php that it stops the wp_password_change_notification() function from being run and that function "Notifies the blog admin of a user changing password" WordPress Developer Reference Commented Mar 10, 2023 at 18:12
3

This works for me, just clear the email address.

// Disable password change notification email.
add_filter('wp_password_change_notification_email', function ($wp_password_change_notification_email) {
    $wp_password_change_notification_email['to'] = '';
    return $wp_password_change_notification_email;
});
1
  • 1
    That's the best way to do it now. When the question was first asked, wp_password_change_notification_email did not exist (it was added in WP 4.9).
    – butlerblog
    Commented Mar 29, 2022 at 16:21
2

Copy this following code and save as disable_email.php . Then place that file in "wp-content/plugins/" directory. And active from Admin Panel.

<?php
/*
Plugin Name: Stop email change password
Description: Whatever
*/

if (!function_exists('wp_password_change_notification')) {
    function wp_password_change_notification($user) {
        return;
    }
}
?>
6
  • ??? How is this different of what I did? Commented Oct 23, 2015 at 8:57
  • Have you made a plugin and placed your code on that ? Commented Oct 23, 2015 at 9:05
  • Yes that is what I thought I described. But I'll update the question if it wasn't clear! Commented Oct 23, 2015 at 9:09
  • try now. I updated the answer. It should work now ! Commented Oct 23, 2015 at 9:13
  • Ha I just found and tried this but didn't work! Commented Oct 23, 2015 at 9:15
2

WordPress sends the notification by default when the user is updated with wp_update_user().

Trying to overwrite this using filters, modifying pluggable.php, or overwriting with an empty function, doesn't work.

Instead use wp_set_password( $password, $user_id ) when you don't want the notification e-mail to be triggered for users/admins on a password reset.

1

Other answers are wrong because those disable sending email when email is changed, not when password is changed.

Adding the code below into your functions.php file under your active theme (or alternatively in a plugin) should work. Worked for me for version 4.6.1

/**
 * Disable sending of the password change email
 */
add_filter( 'send_password_change_email', '__return_false' );

See official documentation

1
  • Not all other answers could be wrong and new answers are posted all the time. You should be more specific in your answer when referring to "other" answers.
    – Sparky
    Commented Dec 10, 2019 at 20:01
1

Use the function wp_set_password() instead of wp_update_user() to update the password as this won't trigger an email notification.

0

Should this answer https://wordpress.stackexchange.com/a/266006/73347 above still work to disable password reset emails to admins?

/**
 * Disable Admin Notification of User Password Change
 *
 * @see pluggable.php
 */
if ( ! function_exists( 'wp_password_change_notification' ) ) {
    function wp_password_change_notification( $user ) {
        return;
    }
}

I'm still receiving them :( Thanks.

0

edit: this is to disable only the admin notifications when any other site user changes their password. I may have misread the question! Apologies =]

The wp_password_change_notification function is responsible for this functionality inside WordPress that emails admins these user password change updates (as other posts have mentioned).

What I haven't seen here is that inside ./wp-includes/default-filters.php ~line 499 (at the time of this writing) you'll see this function being added to the after_password_reset action.

A quick fix is then to simply remove it from the action list:

remove_action( 'after_password_reset', 'wp_password_change_notification' );

You absolutely can rewrite/overwrite wp_password_change_notification, as it is one of the pluggable.php functions, but if you're looking to remove this functionality rather than update it, this might be a better option.

2
  • I will add that after_password_reset action is performed after the password reset procedure (login screen). The sending of a password change notification as a result of profile editing can be controlled by the send_password_change_email filter.
    – nmr
    Commented Mar 4, 2023 at 11:16
  • Wup! Your comment made me realize I might have misread this question. I was looking for a way to disable the admin notification when any site user changes their password. I'll edit to notate that quick - thanks @nmr
    – Rohjay
    Commented Mar 7, 2023 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.