How to Create Custom Reset or Forget Password in WordPress

Many Personal, Blog and or even Business sites that are now running in WordPress platform, the easy and customizable CMS today and when the site goes larger, ineluctable it need custom functionality like Create Custom Reset/Forget Password, Update Profile where user can update their personal information without accessing admin panel and in this tutorial I would like to share you how we can achieve Forgot/reset password functionality using built-in WP functions, it’s very simple just follow the step by step process below.

PHP code

This contains PHP script to update user password and send email containing new password if successful.


This contains simple HTML form code where we put our new password for reset.

Page Template

Below is the complete custom reset password source code you can try just copy and paste the snippet below to try it yourself.

To those who didn’t know yet how to create custom page template visit WP Codex for complete and detailed tutorial.

Happy coding ^_^

by Ryan Sutana

  • Hi,is it possible to show lost password field in login dropdown?

  • adil

    It’s a really very informative information. It’s very useful and knowledgeable for me. i was stuck while coding this. I will bookmark this page for coding help.

  • Biswadip Dasgupta

    Sorry maybe I am missing something but I cannot see how this helps with resetting the password for a user who has forgotten their password?

    • Hi @biswadipdasgupta:disqus I’ve updated the tutorial above it’s been a long time since I’ve posted the solution and WP already provide clean and handy new features, and I take advantage of those, see above, please let me know if it works 😉

  • Biswadip Dasgupta

    Thanks for updating the tutorial Ryan. Unfortunately when I type the username/email address into the text box I get error “ERROR: Enter a username or e-mail address”. So presumably the submit button is not working properly? Incidentally the hidden field on submit was spelt “hiden” so I changed it to “hidden”. Best Bis

    • It should work fine now, I forgot to update the Template code.

  • Towfiq I.

    I am getting 2 errors after submitting the email:

    Error: wpdb::escape is deprecated since version 3.6! Use wpdb::prepare() or esc_sql() instead.
    — Debug: Undefined index: email on line 41 of C:xampp2htdocsnbmwpwp-contentthemesxxxpage-forgotpass.php

    • Hi @TowfiqulIslam:disqus, sorry for that it seems my code is getting old now :D, updated the code.

      • Towfiq I.

        You forgot to change name attribute of the email input field to “email”. like so:

        Thats why it was not working.

        • Update the attribute or change the posted data, it’s up to you, but yeah thanks for pointing that out.

  • Pingback: Custom Forget Password page | Bay Area Web Design()

  • Ulugov

    Many thanks, for so nice tutorial

  • dude

    Shouldn’t you send a link in the email the user has to click? Now everyone can reset a password for someone else…

  • Eslam Foula

    Thank you for this great code, the form rocks.
    I just have one problem that made me crazy (How to avoid form resubmission if user refresh the page after submit the form)?

    Thank you.

  • pingpong

    this is full of errors.
    for once since when does one type “< ?php"
    Why is there a space???

    • I doubt it’s full of error for once it’s working perfectly, the one that keep adding space is the Code Highligther plugin though if you’re a Developer not an arrogant grabber you can easily fix it.