• When i was entered incorrect password i get this message (Error: The password you entered for the username “username” is incorrect. Lost your password?) and this error even when entering the wrong username, an error appears that this username is not registered. Can you help me to fix these errors? I want an error message to appear if the wrong login or password is entered (Incorrect login or password).

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there!


    In WordPress, you can customize the login error message by using the login_errors filter. This filter allows you to modify the error messages displayed on the login page. You can add the following code to your theme’s functions.php file or create a custom plugin to implement this customization:

    function custom_login_error_message($error) {
        // Your custom error message
        $custom_error_message = "Oops! Something went wrong. Please check your credentials and try again.";
    
        // Replace the default error message with your custom message
        return '<strong>' . esc_html($custom_error_message) . '</strong>';
    }
    
    add_filter('login_errors', 'custom_login_error_message');

    In this example, the custom_login_error_message function defines your custom error message, and the login_errors filter is used to replace the default error message with your custom message.

    Remember that modifying core files or themes directly is not recommended, as it can lead to issues during updates. Using a custom plugin or a custom theme is a better practice for making such modifications.

    Additionally, keep in mind that changing the error message might affect the user experience, so it’s important to provide clear and helpful information without compromising security.

    Hii @bakhodirov

    You can use login_errors filter for the same to modify the errors.

    add_filter('login_errors','login_error_message');
    
    function login_error_message($error){
        //check if that's the error you are looking for
        $pos = strpos($error, 'incorrect');
        if (is_int($pos)) {
            //its the right error so you can overwrite it
            $error = "Wrong information";
        }
        return $error;
    }

    Thanks

    Thread Starter bakhodirov

    (@bakhodirov)

    I tried adding the functions in these two comments to the theme’s function.php and saving the change, but nothing changed

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Login page’ is closed to new replies.