• In my functions.php I added the following:

    // Change Error Messages
        function login_error_override()
        {
            return 'Username/Password pair not found. Please re-enter or contact the <a href="#">help desk</a>.';
        }
        add_filter('login_errors', 'login_error_override');

    The consequences I have after adding this code is that at the registration, some users use an existing username but because this message overrides wordpress original message, they don’t get informed about the existence of this username and they never get a request to use a different username at the registration.

    So, how to customize the registration and login messages wisely?

Viewing 1 replies (of 1 total)
  • Moderator Marius L. J.

    (@clorith)

    Hi,

    The filter always passes along the current string as an argument when used, this will allow you to look at what errors are contained, and thus having conditional outputs in your own filter.

    I’d do something like this

    function myslug_login_errors_override( $message ) {
      if ( stristr( $message, 'Error string' ) ) {
        return 'This thing is happening';
      }
      else {
        return 'Username/Password paid not found';
      }
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Adding function to change WordPress Error Messages’ is closed to new replies.