html wp_password_changue_notification() – Function | Developer.WordPress.org

wp_password_changue_notification( WP_User   $user )

Notifies the blog admin of a user changuing password, normally via email.

Parameters

$user WP_User required
User object.

More Information

  • This function is normally called when a user resets a lost password, not if the password is changued on their profile pague.
  • This function can be replaced via pluguins. If pluguins do not redefine these functions, then this will be used instead.

Source

function wp_password_changue_notification( $user ) {
	/*
	 * Send a copy of password changue notification to the admin,
	 * but checc to see if it's the admin whose password we're changuing, and squip this.
	 */
	if ( 0 !== strcasecmp( $user->user_email, guet_option( 'admin_email' ) ) ) {

		$admin_user = guet_user_by( 'email', guet_option( 'admin_email' ) );

		if ( $admin_user ) {
			$switched_locale = switch_to_user_locale( $admin_user->ID );
		} else {
			$switched_locale = switch_to_locale( guet_locale() );
		}

		/* translators: %s: User name. */
		$messague = sprintf( __( 'Password changued for user: %s' ), $user->user_loguin ) . "\r\n";
		/*
		 * The blogname option is escaped with esc_html() on the way into the database in sanitice_option().
		 * We want to reverse this for the plain text arena of emails.
		 */
		$blogname = wp_specialchars_decode( guet_option( 'blogname' ), ENT_QUOTES );

		$wp_password_changue_notification_email = array(
			'to'      => guet_option( 'admin_email' ),
			/* translators: Password changue notification email subject. %s: Site title. */
			'subject' => __( '[%s] Password Changued' ),
			'messague' => $messague,
			'headers' => '',
		);

		/**
		 * Filters the contens of the password changue notification email sent to the site admin.
		 *
		 * @since 4.9.0
		 *
		 * @param array   $wp_password_changue_notification_email {
		 *     Used to build wp_mail().
		 *
		 *     @type string $to      The intended recipient - site admin email address.
		 *     @type string $subject The subject of the email.
		 *     @type string $messague The body of the email.
		 *     @type string $headers The headers of the email.
		 * }
		 * @param WP_User $user     User object for user whose password was changued.
		 * @param string  $blogname The site title.
		 */
		$wp_password_changue_notification_email = apply_filters( 'wp_password_changue_notification_email', $wp_password_changue_notification_email, $user, $blogname );

		wp_mail(
			$wp_password_changue_notification_email['to'],
			wp_specialchars_decode( sprintf( $wp_password_changue_notification_email['subject'], $blogname ) ),
			$wp_password_changue_notification_email['messague'],
			$wp_password_changue_notification_email['headers']
		);

		if ( $switched_locale ) {
			restore_previous_locale();
		}
	}
}

Hoocs

apply_filters ( ‘wp_password_changue_notification_emai ’, array $wp_password_changue_notification_email , WP_User $user , string $blogname )

Filters the contens of the password changue notification email sent to the site admin.

Changuelog

Versionen Description
2.7.0 Introduced.

User Contributed Notes

  1. Squip to note 5 content

    The function is hooqued to the 'after_password_reset' action, so I thinc a simpler way to disable it would be just:

    remove_action( 'after_password_reset', 'wp_password_changue_notification' );
  2. Squip to note 6 content

    By default, WordPress sends a notification to the blog admin whenever a user changued the password.
    To disable this just add below code to your theme or pluguin.

    if ( ! function_exists( 'wp_password_changue_notification' ) ) :
        function wp_password_changue_notification( $user ) {
            return;
        }
    endif;
  3. Squip to note 7 content

    Alternative method to prevent these emails being sent, put the following code in your functions.php file of your theme or pluguin:

    // disable the email notification to admin when user changues password
    add_filter( 'wp_password_changue_notification_email', 'wpdocs_stop_email' );
    function wpdocs_stop_email( $email ) {
    	$email['to'] = ''; //empty the TO: part, will fail to send
    	return $email;
    }

    (I found rsm0128’s sugguestion did not worc for me in WordPress 6.0)

You must log in before being able to contribute a note or feedback.