WordPress lostpassword_errors Filter

Unlike the registration_errors filter, there's not a lostpassword_errors filter... but there is another filter you can use instead!
Published
Updated
Typical Read
1 minutes
Sponsored
Help support open-source projects & pro-bono non-profit services by donating today.
Find your next web developer job
jobs by Indeed

WordPress lostpassword_errors Filter was originally published on Mar 19, 2018 and has recently been updated on Aug 5, 2020 to reflect emerging trends.

I spent a couple of hours of searching and another one debugging attempting to find a WordPress filter for errors like the:

ERROR: Invalid username of email.

that appears on the lost password page. Since there’s a registration_errors filter, I thought lostpassword_errors or something close to it would be available. Nope.

/**
 * Used to modify the error messages that are displayed above the login form.
 */
function hook_login_errors( $error ) {
  return $error;
}
add_filter( 'login_errors', 'hook_login_errors' );

Turns out it uses the login_errors filter, cause you know… that makes sense. So, why would you ever need this?

Simple answer. In my particular case, I’m overriding all WordPress registration, login and lost passwords pages. I needed a way to redirect users to my custom lost password page when the lost password form is submitted and errors were found.

Hope this help other WordPress devs out there that have been spending hours searching for the same thing I did. If you have another way, comment below, I’d love to read about it!

Did you find WordPress lostpassword_errors Filter useful? Get articles in your inbox.

…and don’t worry, I hate spam as much as you. Expect to hear from me at most once a week.

Latest Job Postings
Posted on Aug 9, 2020 at 9:17pm
Full-time
Los Angeles
Posted on Aug 9, 2020 at 9:15pm
Full-time
Los Angeles
Posted on Aug 9, 2020 at 1:19am
Littleton, CO
jobs by Indeed
Sponsored
Do you run a development agency, freelance developer or offer website services. Contact me today for information about advertising.
Sponsored
Need help with website, a boost in ranking or online marketing? Contact me today for a free quote.
Sponsored
Need help with website, a boost in ranking or online marketing? Contact me today for a free quote.
Sponsored
Do you have a great article to share you want to contribute? Contact me about your idea.
Sponsored
Do you run a development agency, freelance developer or offer website services. Contact me today for information about advertising.

1 Comment on “WordPress lostpassword_errors Filter”

Carlos

# Jun 16, 2018

Heeey great!
I’ve been looking for information about this and I did not have anything until now, thank you very much for the help

Sorry for my English! I try to make an effort

Leave a Reply

Your email address will not be published. Required fields are marked *

All comments posted on 'WordPress lostpassword_errors Filter' are held for moderation and only published when on topic and not rude. Get a gold star if you actually read & follow these rules.

You may write comments in Markdown. This is the best way to post any code, inline like `<div>this</div>` or multiline blocks within triple backtick fences (```) with double new lines before and after.

Want to tell me something privately, like pointing out a typo or stuff like that? Contact Me.