Home / Archive / MemberPress: Customize Default WordPress Password Reset Request Email Body
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Customize Default WordPress Password Reset Request Email Body

This code snippet customizes the body of the password reset request email sent to users from "yourdomain.com/wp-login.php?action=lostpassword".

The code replaces the default message with a custom one. The sample below will add the personalized “Hi [username], you recently requested a password reset for your account.” custom text. The rest of the email template remains unchanged.

To change the message, replace or modify the “Hi ' . $user_login . ', you recently requested a password reset for your account.” text with the new text on this lines:

$message = __( 'Hi ' . $user_login . ', you recently requested a password reset for your account.', 'text_domain' ) . "n";

To include additional messages in the email, you can copy the rows mentioned above and paste it below. For example,

$message = __( 'Hi ' . $user_login . ', you recently requested a password reset for your account.', 'text_domain' ) . "n";
$message .= __( 'Please click the link below to reset your password:', 'text_domain' ) . "n";
$message .= __( 'Your password reset link', 'text_domain' ) . "n";

Code Preview
php
<?php
function simple_password_reset_message( $message, $key, $user_login ) {
  // Custom message for the password reset email
  $message = __( 'Hi ' . $user_login . ', you recently requested a password reset for your account.', 'text_domain' ) . "\n";
  // Rest of the email content remains unchanged (optional to add here if needed)
  return $message;
}
// Hook the function to the 'retrieve_password_message' filter to customize the email body
add_filter( 'retrieve_password_message', 'simple_password_reset_message', 20, 3 );

Comments

Add a Comment