9

From the wp admin login page I click to reset my password (not on the theme, on wp). I get the email but it contains no url to click. Plugins are disabled. What shoud I do?

4
  • 1
    then what does it sends? Commented Nov 16, 2016 at 13:22
  • I't sends an email about somebody asked for a new password and I have to verify by clickin to the following link. But there's no link, just a blank line.
    – tt24
    Commented Nov 24, 2016 at 17:58
  • I have the exact same issue for years: how come this haven't been fixed by WordPress already? Is it that not widespread?
    – CDuv
    Commented May 13, 2019 at 10:50
  • This bug is still exists in WordPress. I have no idea why not fixed.
    – Feriman
    Commented Dec 1, 2019 at 18:13

5 Answers 5

10

The problem is the < and > which surround the reset URL in wp-login.php. You can remove them using retrieve_password_message in your theme functions.php file like below:

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;

}
4
  • what is 99 & 4 in below line can any one explain me ? add_filter("retrieve_password_message", "mapp_custom_password_reset", 99, 4); above answer is working for me but i dont know about last 2 parameters.
    – Amit Joshi
    Commented Jan 11, 2020 at 14:17
  • what is 99 & 4 in below line can any one explain me ? add_filter("retrieve_password_message", "mapp_custom_password_reset", 99, 4); above answer is working for me but i dont know about last 2 parameters. and how can i get them to pass in filter ?
    – Amit Joshi
    Commented Jan 11, 2020 at 14:31
  • 1
    The 99 is the priority and the 4 is the number of arguments that will be passed to the callback function - developer.wordpress.org/plugins/hooks/actions/…
    – Luke Seall
    Commented Jan 13, 2020 at 10:02
  • Why are the greater than and less than characters causing an issue? I've never seen this happen before... Commented Mar 11, 2020 at 14:39
3

If you only want to remove the angle brackets WordPress added but let the rest of the generated message unchanged, add the following to the functions.php of your WordPress theme (eg. wp-content/themes/some_awesome_theme/functions.php).

/**
 * Removes angle brackets (characters < and >) arounds URLs in a given string
 *
 * @param string $string    The string to remove potential angle brackets from
 *
 * @return string    $string where any angle brackets surrounding an URL have been removed.
 */
function remove_angle_brackets_around_url($string)
{
    return preg_replace('/<(' . preg_quote(network_site_url(), '/') . '[^>]*)>/', '\1', $string);
}

// Apply the remove_angle_brackets_around_url() function on the "retrieve password" message:
add_filter('retrieve_password_message', 'remove_angle_brackets_around_url', 99, 1);
1

Check out the wp-login.php on GitHub.

The default blocks looks like:

// Redefining user_login ensures we return the right case in the email.
$user_login = $user_data->user_login;
$user_email = $user_data->user_email;
$key = get_password_reset_key( $user_data );
if ( is_wp_error( $key ) ) {
    return $key;
}
$message = __('Someone has requested a password reset for the following account:') . "\r\n\r\n";
$message .= network_home_url( '/' ) . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
$message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
$message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n";

You should be able to filter the password reset message with 'retrieve_password_message' and change it to what you need.

$message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
1

I had this problem and wanted to share how I solved it here.

I opened the email and to the right where you would see the time stamp of when you got the email, there will be three dots.

Click on that and then click "show original"

From there you will see the code for the email. Look for the part of the email where it says you should click on the link.

Copy the link that is within the < > marks. Paste it into your browser and voila, you will be able to reset.

1

I had this problem and did similar to Travis...

  1. right click on the email message
  2. select view source
  3. copy the link you see below the words 'To reset your password, visit the following address:'
  4. paste it into your domain box and hey presto.

hope this helps too :)

Not the answer you're looking for? Browse other questions tagged or ask your own question.