I’m trying to send a password reset link to a newly created user within WordPress. However when i do this, the password reset link says it’s invalid. I have the following code:
public function __construct() {
add_filter('wp_new_user_notification_email', array($this, 'custom_wp_new_user_notification_email'), 10, 3);
}
public function custom_wp_new_user_notification_email($wp_new_user_notification_email, $user, $blogname)
{
$key = get_password_reset_key($user);
$password_link = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login');
...
// After this i'm sending the password reset e-mail
}
The $password_link variable comes out looking like this:
https://domainname.nl/wp-login.php?action=rp&key=YLzQKchRRPS6Cu2pkmVA&login=jordi
What am i doing wrong here? Looks like a valid password reset link to me.