apply_filters( ‘retrieve_password_message’, string $message, string $key, string $user_login, WP_User $user_data )

Filters the message body of the password reset mail.

Description

If the filtered message is empty, the password reset email will not be sent.

Parameters

$messagestring
Email message.
$keystring
The activation key.
$user_loginstring
The username for the user.
$user_dataWP_User
WP_User object.

Source

$message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );

Changelog

VersionDescription
4.1.0Added $user_login and $user_data parameters.
2.8.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    You have to add the following piece of code into your Child’s Theme file “functions.php” and update the file.

    /**
     * Filter password reset request email's body.
     *
     * @param string $message
     * @param string $key
     * @param string $user_login
     * @return string
     */
    function wpdocs_retrieve_password_message( $message, $key, $user_login ) {
    	$site_name  = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    	$reset_link = network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' );
    
    	// Create new message
    	$message = __( 'Someone has requested a password reset for the following account:' . $user_login, 'text_domain' ) . "\n";
    	$message .= sprintf( __( 'Site Name: %s' ), network_home_url( '/' ) ) . "\n";
    	$message .= sprintf( __( 'Username: %s', 'text_domain' ), $user_login ) . "\n";
    	$message .= __( 'If this was a mistake, just ignore this email and nothing will happen.', 'text_domain' ) . "\n";
    	$message .= __( 'To reset your password, visit the following address:', 'text_domain' ) . "\n";
    	$message .= $reset_link . "\n";
    
    	return $message;
    }
    
    add_filter( 'retrieve_password_message', 'wpdocs_retrieve_password_message', 20, 3 );

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