Friendlier Password Reset Email
Replaces the wording of the password reset email with a clearer message and subject, keeping the reset link intact.
Opens WPIDE on
Code
add_filter( 'retrieve_password_title', function () {
return sprintf( 'Reset your %s password', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
} );
add_filter( 'retrieve_password_message', function ( $message, $key, $user_login, $user ) {
$url = network_site_url( 'wp-login.php?action=rp&key=' . $key . '&login=' . rawurlencode( $user_login ), 'login' );
return sprintf( "Hi %s,\n\n", $user->display_name ? $user->display_name : $user_login )
. "We received a request to reset the password for your account.\n\n"
. "Choose a new password here:\n" . $url . "\n\n"
. "If you did not ask for this, you can ignore this email and your password will stay the same.\n";
}, 10, 4 );
Notes
The reset link expires after 24 hours by default.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.