0

I'm trying to add custom wording to the basic WordPress registration password set/reset email. I'm using the plugin New User Approve to approve all users, but that doesn't seem to impact my issue. The problem is that the password set/rest link I'm emailing is identical to the default Wordpress link - except of course for the keys - but it doesn't work.

The default WordPress emailed link looks like this:

https://example.com/wp-login.php?action=rp&key=gicOc3FFIcDzf5WZvKBV&login=username

My emailed link looks like this:

https://example.com/wp-login.php?action=rp&key=V9gnJAe359tkn2dPOMXo&login=username

The default link works; my link throws the message "Your password reset link appears to be invalid. Please request a new link below."

How can I get my custom email to link to the password setting page https://example.com/wp-login.php?action=rp and not https://example.com/wp-login.php?action=lostpassword&error=invalidkey

Is the key not valid? Expired? Not output correctly? Using rawurlencode($user_login); from Check Password Reset Key Not Woking does not help.

To generate the custom email, I'm using

  function my_custom_message( $message, $user ) {

            $user_login = stripslashes($user->user_login);
            $key = get_password_reset_key( $user_data );

       $rp_link =  wp_login_url() ."?action=rp&key=$key&login=" . rawurlencode($user_login); 
    return $rp_link;
}

        return $rp_link;
    }
    // add a new custom approval message
    add_filter( 'new_user_approve_approve_user_message', 'my_custom_message', 10, 2 );
3
  • duplicated issue
    – idpokute
    May 24, 2018 at 17:42
  • according the answer, you need to use rawurlencode methods to $user_login.
    – idpokute
    May 24, 2018 at 17:43
  • @idpokute using rawurlencode($user_login) does not help. May 24, 2018 at 18:26

1 Answer 1

0

The error (flagged in debug) was that I was using $user_data in the line

$key = get_password_reset_key( $user_data );

instead of $user.

Works now on WP 4.9.6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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