Categories
Common Problems How To

How to solve WordPress missing URL in password reset email

I run a WordPress e-commerce site. Recently I have received support requests from customers informing me they are not able to reset their WordPress account password.

I decided to look it up myself. I clicked on forgot password link on WordPress login page. I supplied my account email and clicked on the button to submit the reset request.

I checked my email and opened the reset email sent. However, the email reset link did not have the password reset link.

WordPress password reset email no link

Upon investigation, I noticed the current theme I use strips the password reset link. The specific issue is the angle brackets i.e. < and > which surround the reset URL in wp-login.php.

To solve the problem, we need to add code that will prevent the theme from stripping links on emails. We shall edit the theme’s functions.php and add the following code at the end of functions.php.

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";


    return $message;

}

Once done, save and refresh the website. Your users can now reset the password via wp-login.php via forgot password reset link and voila! Users should be able to receive an email with the password reset link.

WordPress password reset email with link

That should be it!

By WP Array

Ex Dreamweaver...yeah! Ex Modx, Ex Joomla. 2 years of web design experience, 3 years UX/UI designer and 8 years of web experience. Wordpress convert and enthusiast! Let's do this for the love of the web.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.