I'm trying to change the confirmation link with key and username sent by wordpress when a user forget his password. The link looks like:


And I want to change it this way:


But I don't know what filter I must use to change it.

Thank you in advance for your help and time.

Found a solution, putting this code in my theme functions.php. Maybe there's a best solution out there... I think change all the message is not a good way:

function reset_password_message( $message, $key ) {

if ( strpos($_POST['user_login'], '@') ) {
    $user_data = get_user_by('email', trim($_POST['user_login']));
} else {
    $login = trim($_POST['user_login']);
    $user_data = get_user_by('login', $login);

$user_login = $user_data->user_login;

$msg = __('The password for the following account has been requested to be reset:'). "\r\n\r\n";
$msg .= network_site_url() . "\r\n\r\n";
$msg .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$msg .= __('If this message was sent in error, please ignore this email.') . "\r\n\r\n";
$msg .= __('To reset your password, visit the following address:');
$msg .= '<' . network_site_url("new-password/?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n";

return $msg;


add_filter('retrieve_password_message', reset_password_message, null, 2);
  • Why are you needing to do this? – s_ha_dum May 9 '14 at 14:24
  • Thanks for your response. Because I'm using a custom page for bbpress forum who receives key and user to make a lost-password process. This way I want to hide wp-login and wp-admin to users. All process is working right now but the autogenerated email link uses wp-login.php instead of /new-password/ who is my login page for users. – JBoy May 9 '14 at 14:46
  • @JBoy, please put your solution in an answer and remove it from the question. – Mikael Dúi Bolinder May 9 '14 at 17:17
  • that function works and lets you modify also the text of the message sent to invite the user to reset its password. – Pons Apr 24 '17 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.