Site icon Hip-Hop Website Design and Development

Customizing login error messages

The place and the way would I be capable of customise the login error messages?

"Error: The username <> is not registered on this site. If you are unsure of your username, try your email address instead."

and
"Error: The password you entered for the username <> is incorrect. Lost your password?"

I’ve tried utilizing this code, however nothing. Any assist can be appreciated!

    international $errors;
    $err_codes = $errors->get_error_codes();

    // Invalid username.
    if ( in_array( 'invalid_username', $err_codes ) ) {
        $error = '<robust>ERROR</robust>: This electronic mail handle shouldn't be registered. Please verify or contact XXX for extra data.';
    }

    // Incorrect password.
    if ( in_array( 'incorrect_password', $err_codes ) ) {
        $error = '<robust>ERROR</robust>: The password you supplied is wrong. Please strive once more or contact XXX for extra data. ';
    }

    return $error;
}

add_filter( 'login_errors', 'my_custom_error_messages');```