WordPress Customize Forgot Password Email

In this tutorial, we will walk you through a very simple process regarding Customize Forgot Password Email. By default, WordPress sends an email with basic information when someone fills in the forgot password form. Default email for forgot password looks something like this.

 

In general, we skip updating the email templates for this when creating a project for someone because we never consider this in our milestones. If you are the one who considers this as a milestone for the project and wants to Customize Forgot Password Email then this tutorial is for you and believe me it’s very simple.

Prerequisite

  • A WordPress installed
  • An active parent or child theme (as we will add the code to that)
  • Access to the files.
  • SMTP is configured to send and test the emails.

If you have all the above then let’s start!!!

Step 1 – Override filter for an email message

First of all, we need to override a filter called “retrieve_password_message“. To do so, add the following code to your active theme’s functions.php file:

Step 2 – Add a callback function

Now we have our filter added. The second parameter given “tutsocean_retrieve_password_message” is the name of the callback function so now our next step is to add the callback function to the same functions.php file

Up to this, the email template/message has been updated. You can make changes to the above callback function to update the message.

See how easy it is and we always neglect this easy step while delivering the project to the client.

If you want the simple email, you can close from here, but if you are interested in sending some beautiful email using some HTML, you can proceed further and make some more changes to the code.

Customize Forgot Password Email with some HTML

For this, you have to neglect the above step 2 and use the following code as the callback function for your filter. Add the following code in your active theme’s functions.php file:

We have added the line to require a file from the emails folder [Line number 5]. This line means you have to create a folder with the name “emails” in your active theme and then create a file with “forgot_password.php”. After creating the file, add the following code to that file and save it.

This is all you need to Customize Forgot Password Email