0

I found some similar questions on here, but was unable to apply the solutions that were provided.

The standard password reset email that Wordpress is sending does not provide a clickable url for users resetting their password. Here's what the current email looks like: enter image description here

It appears that the site url (https://jewelbound.com) should be at the bottom, connected to the "/wp-login.php?action......"

Please help me know how to modify the following email template code in order to remove the "https://jewelbound.com/" url from the top, add it to the provided url at the bottom, and make it one long, connected (and clickable) url that will allow the user to reset their password. Here's the template from my wp-login.php file:

$message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n";
    /* translators: %s: site name */
    $message .= sprintf( __( 'Site Name: %s'), $site_name ) . "\r\n\r\n";
    /* translators: %s: user login */
    $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";

    /* translators: Password reset email subject. %s: Site name */
    $title = sprintf( __( '[%s] Password Reset' ), $site_name );

Thanks in advance for anyone willing to help!

2

To answer your specific question, "How can I modify the default reset (lost) password email text," the answer would be to use the retrieve_password_message filter. And ultimately that might be a way to solve your problem.

But I think you need to dig a little deeper to figure out what's really going on. In your question you asked about modifying the "default reset password email text" but what you actually have isn't the real default. If it was, the URL string would all be together, not separated as it is now.

I would start by deactivating all plugins and switching over from whatever theme is being used to use the WP default theme. In other words, a very basic install with no interference. Try it then. If you don't get the same result, then somewhere there is something that is messing up the URL. There are filters for retrieve_password_message and network_site_url that could allow for some filter function somewhere to be causing your issue. Disabling plugins and using a basic theme without modification should lead you to discover if that's the case.

Ultimately, if you can't trace it down, then rewriting the entire message content in the context of the retrieve_password_message filter will give you a work-around from whatever the problem is. The filter below reproduces the default message. It includes a potential workaround of the URL generation in case something hooked to network_site_url is the culprit. If it is, use the alternative and hardcode the domain as indicated.

add_filter( 'retrieve_password_message', 'my_retrieve_password_message', 10, 4 );
function my_retrieve_password_message( $message, $key, $user_login, $user_data ) {

    // Start with the default content.
    $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    $message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n";
    /* translators: %s: site name */
    $message .= sprintf( __( 'Site Name: %s' ), $site_name ) . "\r\n\r\n";
    /* translators: %s: user login */
    $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";

    /*
     * If the problem persists with this filter, remove
     * the last line above and use the line below by
     * removing "//" (which comments it out) and hard
     * coding the domain to your site, thus avoiding
     * the network_site_url() function.
     */
    // $message .= '<http://yoursite.com/wp-login.php?action=rp&key=' . $key . '&login=' . rawurlencode( $user_login ) . ">\r\n";

    // Return the filtered message.
    return $message;

}

Your Answer

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

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