password_change_email

Home » Hooks » password_change_email

The password_change_email hook is a WordPress action hook that is triggered when a user’s password is changed and an email notification is sent to the user. This hook allows developers to modify or customize the email sent to the user when their password is changed.

This hook can be useful in scenarios where you want to customize the email template, add additional information, or even send the notification to a different email address. By using this hook, you have the flexibility to modify the content of the email and tailor it to your specific needs.

Here’s an example of how you can use the password_change_email hook:

function custom_password_change_email( $user_email, $subject, $message, $user ) {
    // Modify the subject of the email
    $subject = 'Your password has been changed successfully';

    // Add custom content to the email message
    $message .= 'We wanted to inform you that your password has been changed.';

    // Send the email to a different email address
    $user_email = 'customemail@example.com';

    // Return the modified email details
    return array( $user_email, $subject, $message, $user );
}
add_filter( 'password_change_email', 'custom_password_change_email', 10, 4 );

In this example, the custom_password_change_email function is hooked to the password_change_email hook using the add_filter function. Inside the function, we modify the subject of the email, add custom content to the message, and change the recipient email address.

By using this hook and customizing the function, you can easily customize the password change email sent to users in your WordPress website.

Learn More on WordPress.org

WordPress snippets using the password_change_email hook

Register an account to save your snippets or go Pro to get more features.