How to apply the “retrieve_password_message” filter?

the given answers have good intentions. But are not good. There are more parameters to the filter function call, 4 to be exact.

this worked for me for the message (i wanted to replace username with user email)

note we have a multi site page. You might want to replace network_site_url with get_site_url()

typically in your functions.php of your wordpress stheme:

add_filter("retrieve_password_message", "mapp_custom_password_reset", 99, 4);

function mapp_custom_password_reset($message, $key, $user_login, $user_data )    {

  $message = "Someone has requested a password reset for the following account:

" . sprintf(__('%s'), $user_data->user_email) . "

If this was a mistake, just ignore this email and nothing will happen.

To reset your password, visit the following address:

" .  '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n" . "

If you have any further issues, please email us to [email protected]

The Myapp Team";


  return $message;

}

bonus: change email title / subject

add_filter( 'retrieve_password_title',
  function( $title )
  {
    $title = __( 'Password reset for myapp.org' );
    return $title;
  }
);

Leave a Comment

tech