[Plugin: Theme My Login] Custom error message for failed login (2 posts)

  1. ankitvatsa
    Posted 6 years ago #

    Suppose a user gives incorrect username while login, he gets an error message,

    Invalid Username, Forgot your password?

    I want to change this error message. How to do that ?

  2. Jeff Farthing
    Posted 6 years ago #

    Hmm, this is a WordPress core message and does not have a direct filter. The login provides a filter, but this is a filter on the concatenated login error messages, so if there is more than one error, it could be a bit tricky. You could try an str_replace():

    function change_invalid_username_message( $message ) {
        return str_replace( sprintf(__('<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login')), 'Your message here.', $message );
    add_filter( 'login_errors', 'change_invalid_username_message' );

Topic Closed

This topic has been closed to new replies.

About this Topic