Skip to content

Change WordPress Login Message – Filter It Out

This is an add-on to my last post about customizing the login page. My client wanted to (very slightly) change the text a user sees on the Forgot Password page.

It took me way too long to come across the login_message filter.

here’s my function:

function forgotpass_message() {
 $action = $_REQUEST['action'];
 if( $action == 'lostpassword' ) {
 $message = '<p class="message">Please enter your email address. Then check your email inbox for instructions to reset your password.</p>';
 return $message;
 }
}
add_filter('login_message', 'forgotpass_message');

The url on the forgot password page includes the query string “action=lostpassword” so that’s what I’m checking for with my $_REQUEST call. If we’re on the forgot password page, then make a new message and return it.

Some other possible values of the action query string (taken from wp-login.php):

  • logout
  • retrievepassword
  • resetpass
  • rp
  • register
  • login

I think “rp” is another form of reset password.

Happy WordPress login page customizing! Hopefully someone who is looking for this comes across it quicker than I did.

5 Comments (Add Yours)

  1. Just what I needed!

    Thanks for sharing mate :)

  2. Very useful. Looked for it for a while. Thank you very much!

  3. Many many thanks bro.

    I have one more query and i think you can help me to solve that.
    In wordpress i want to change lost your password to forgot password. Then what is the best practice?

    I did it via add_filter(gettext).

    • Hey Seeker, I’m really sorry, somehow this comment slipped through the cracks. I think that’s about the only way to do it. I took a quick look at wp-login.php and there doesn’t seem to be any filters around there to use.

  4. Just what I was looking for, thanks for sharing this!

Add Your Comment (Get a Gravatar)

Get a Gravatar! Your Name

*

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