Support » Plugin: Login With Ajax » [Plugin: Login With Ajax] How To Change Error Notices

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Marcus


    This is standard WP errors, not sure if there’s a plugin that’d change those errors

    This one as well is from wp?

    ERROR: The password you entered for the username demo is incorrect. Lost your password?

    I installed a plugin that takes care of the other messages but this one is the only one remaining. Could it be that Login with ajax is handling this one?

    What is the name of the plugin you used to change the standard messages?

    Unified login error messages



    I found these error messages, they live in /wp-includes/user.php

    Now I just need to find a way of changing them without touching the source WP code.

    Any clues anyone?



    Hello, Wasca!

    Im having same problem, and I guess I’ve found a way to change any of those messages. I think it’s not the right way I do it, but it works for me well =)

    You won’t need to modify WP core files, but you will need to edit one of the plugin’s PHP files – it’s called login-with-ajax.php.

    This file is located right inside login-with-ajax plugin folder.

    So basically, the idea is to catch up error messages and replace them with your custom ones. All messages are handled through the WP native class WP Error.

    Read up some usefull info, using this link above. When you’re done, you will then understand, that login-with-ajax plugin sends our post data (all that user fills into input fields during registration or login) and then receives answer, containing an error, if there is one.

    So now, look up into our login-with-ajax.php file and find line 195 and 226. It’s those one lines, where an error result returns:

    $return['error'] = $loginResult->get_error_message(); // For Login fields
    $return['error'] = $errors->get_error_message(); // For registration fields

    Since plugin uses get_error_message() function, and we’re already having some translation files, this error message will return already translated. So, we need to receive some other data to work with. Reading up class reference about WP error once again, you can find some other function called get_error_code(). So, let’s replace get_error_message() with get_error_code() and see what happens on the site:

    $return['error'] = $loginResult->get_error_code();
    $return['error'] = $errors->get_error_code();

    You will now be able to see error codes instead of real human-readable error messages. Now, you can str_replace this error codes with some custom stuff. To do so, add these line after your modified 195 and 226 lines:

    $return['error'] = str_replace('empty_username', 'Oh my, you have no name, sir?', $return['error']);

    This example will replace an error message if the registration form’s username is empty. You can check up all the other error codes by your own and str_replace them your own way 🙂


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Login With Ajax] How To Change Error Notices’ is closed to new replies.