Are you developing a registration and login interface for users on your website? And you wonder how to create a password reset link for the user. In this article I will show you how to do this.

Create password reset link
Let’s say you have a registration page and on successful registration an email is sent to the user to set a password.
Or you have a forgot password page and a password reset link will be sent to the user after they enter their email address in the form.
And you can easily create that link with the code below:
<?php /*@ Create reset password link */
$user = new WP_User( (int) $user_id );
$reset_key = get_password_reset_key( $user );
$user_login = $user->user_login;
$rp_link = '<a href="'%20.%20network_site_url(" wp-login.php . rawurlencode>Set password link</a>';
<div>
<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span>
</div>
You can now use the $rp_link variable to send a reset password link in an email.
Explain
Using WP_User() class , I am accessing the person object with the help of the variable user_id . Then I’m passing that user object to the get_password_reset_key() function to get the password reset key stored in the database.
This password reset key allows $user to change the password.
Finally, I created the full password reset link. With the help of function network_site_url() returns the URL of the current website.
Epilogue
I hope this article will help you to successfully create a WordPress user password reset link.
Please leave a comment if you have any questions. If you found the previous article useful, you can follow the WordPress Tips section and follow Facebook for more new knowledge.

