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!


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!

Author: Ben Marshall

Red Bull Addict, Self-Proclaimed Grill Master, Entrepreneur, Workaholic, Front End Engineer, SEO/SM Strategist, Web Developer, Blogger

One thought on “WordPress lostpassword_errors Filter”

  1. 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.