# wp_password_change_notification()

URL: https://chugunov.pro/api-wordpress/functions/wp_password_change_notification/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.7.0.

## Сигнатура

```php
wp_password_change_notification( WP_User $user )
```

## Описание

Уведомляет администратора блога о смене пароля пользователем, обычно по электронной почте.

## Параметры

- `$user` `WP_User` — обязательный. Объект пользователя.

## Исходный код

Файл: `wp-includes/pluggable.php:2191`

```php
function wp_password_change_notification( $user ) {
	/*
	 * Send a copy of password change notification to the admin,
	 * but check to see if it's the admin whose password we're changing, and skip this.
	 */
	if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {

		$admin_user = get_user_by( 'email', get_option( 'admin_email' ) );

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

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

		$wp_password_change_notification_email = array(
			'to'      => get_option( 'admin_email' ),
			/* translators: Password change notification email subject. %s: Site title. */
			'subject' => __( '[%s] Password Changed' ),
			'message' => $message,
			'headers' => '',
		);

		/**
		 * Filters the contents of the password change notification email sent to the site admin.
		 *
		 * @since 4.9.0
		 *
		 * @param array   $wp_password_change_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 $message The body of the email.
		 *     @type string $headers The headers of the email.
		 * }
		 * @param WP_User $user     User object for user whose password was changed.
		 * @param string  $blogname The site title.
		 */
		$wp_password_change_notification_email = apply_filters( 'wp_password_change_notification_email', $wp_password_change_notification_email, $user, $blogname );

		wp_mail(
			$wp_password_change_notification_email['to'],
			wp_specialchars_decode( sprintf( $wp_password_change_notification_email['subject'], $blogname ) ),
			$wp_password_change_notification_email['message'],
			$wp_password_change_notification_email['headers']
		);

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

## История изменений

- 2.7.0 — Introduced.

## Связанные

Использует: [`switch_to_user_locale`](https://chugunov.pro/api-wordpress/functions/switch_to_user_locale/), [`restore_previous_locale`](https://chugunov.pro/api-wordpress/functions/restore_previous_locale/), [`switch_to_locale`](https://chugunov.pro/api-wordpress/functions/switch_to_locale/), [`get_locale`](https://chugunov.pro/api-wordpress/functions/get_locale/), [`wp_specialchars_decode`](https://chugunov.pro/api-wordpress/functions/wp_specialchars_decode/), [`get_user_by`](https://chugunov.pro/api-wordpress/functions/get_user_by/), [`wp_mail`](https://chugunov.pro/api-wordpress/functions/wp_mail/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_password_change_notification/
