Filter hook 'password_change_email'

in WP Core File wp-includes/user.php at line 2771

View Source

password_change_email

Filter Hook
Description
Filters the contents of the email sent when the user's password is changed. The following strings have a special meaning and will get replaced dynamically: - ###USERNAME### The current user's username. - ###ADMIN_EMAIL### The admin email in case this was unexpected. - ###EMAIL### The user's email address. - ###SITENAME### The name of the site. - ###SITEURL### The URL to the site. }

Hook Information

File Location wp-includes/user.php View on GitHub
Hook Type Filter
Line Number 2771

Hook Parameters

Type Name Description
array $pass_change_email { Used to build wp_mail().
array $user The original user array.
array $userdata The updated user array.

Usage Examples

Basic Usage
<?php
// Hook into password_change_email
add_filter('password_change_email', 'my_custom_filter', 10, 3);

function my_custom_filter($pass_change_email, $user, $userdata) {
    // Your custom filtering logic here
    return $pass_change_email;
}

Source Code Context

wp-includes/user.php:2771 - How this hook is used in WordPress core
<?php
2766  		 *     @type string $headers Headers. Add headers in a newline (\r\n) separated string.
2767  		 * }
2768  		 * @param array $user     The original user array.
2769  		 * @param array $userdata The updated user array.
2770  		 */
2771  		$pass_change_email = apply_filters( 'password_change_email', $pass_change_email, $user, $userdata );
2772  
2773  		$pass_change_email['message'] = str_replace( '###USERNAME###', $user['user_login'], $pass_change_email['message'] );
2774  		$pass_change_email['message'] = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' ), $pass_change_email['message'] );
2775  		$pass_change_email['message'] = str_replace( '###EMAIL###', $user['user_email'], $pass_change_email['message'] );
2776  		$pass_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $pass_change_email['message'] );

PHP Documentation

<?php
/**
		 * Filters the contents of the email sent when the user's password is changed.
		 *
		 * @since 4.3.0
		 *
		 * @param array $pass_change_email {
		 *     Used to build wp_mail().
		 *
		 *     @type string $to      The intended recipients. Add emails in a comma separated string.
		 *     @type string $subject The subject of the email.
		 *     @type string $message The content of the email.
		 *         The following strings have a special meaning and will get replaced dynamically:
		 *         - ###USERNAME###    The current user's username.
		 *         - ###ADMIN_EMAIL### The admin email in case this was unexpected.
		 *         - ###EMAIL###       The user's email address.
		 *         - ###SITENAME###    The name of the site.
		 *         - ###SITEURL###     The URL to the site.
		 *     @type string $headers Headers. Add headers in a newline (\r\n) separated string.
		 * }
		 * @param array $user     The original user array.
		 * @param array $userdata The updated user array.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/user.php
Related Hooks

Related hooks will be displayed here in future updates.