Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Customizing login error messages

I can’t see your complete code… However, your code should look like this:

function my_custom_error_messages( $error ) {
    global $errors;
    $err_codes = $errors->get_error_codes();
 
    // Invalid username.
    // Default: '<strong>ERROR</strong>: Invalid username. <a href="%s">Lost your password</a>?'
    if ( in_array( 'invalid_username', $err_codes ) ) {
        $error="<strong>ERROR</strong>: Wrong username.";
    }
 
    // Incorrect password.
    // Default: '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s">Lost your password</a>?'
    if ( in_array( 'incorrect_password', $err_codes ) ) {
        $error="<strong>ERROR</strong>: Wrong password.";
    }
 
    return $error;
};
add_filter( 'login_errors', 'my_custom_error_messages' );

The code above has been tested and worked.

Related Posts:

  1. WordPress error on log out ‘Not Permitted’ and can’t log out
  2. How to place wp-login.php in page or page template?
  3. How can I redirect user after entering wrong password?
  4. ‘Password field is empty’ error when using autofill in Chrome
  5. Custom login form
  6. Prevent wp_login_form() from redirecting to wp-admin when there are errors
  7. How do I change the language of only the login page?
  8. Disable WordPress 3.6 idle logout / login modal window / session expiration
  9. Avoid to load default WP styles in login screen
  10. How to fake a WordPress login?
  11. Can not login with correct username and password
  12. How can I add a custom script to footer of login page?
  13. How to keep always logged in development environment
  14. Integrate recaptcha and wp_signon – what is needed?
  15. I want to disable E-Mail verifcation / activation when a user signs up for my WordPress site
  16. custom login page redirect to logged in user profile page
  17. Receiving “This content cannot be displayed in a frame” error on login page
  18. Action wp_login_failed not working if only one field is filled out
  19. How to customise wp-login.php only for users who are setting a password for the first time?
  20. WordPress Login Footer URL
  21. Remove built in wordpress login and use only google auth
  22. Change Login Page for a Multisite Subsite
  23. Positioning the “Lost your password?” and “← Back to Site”
  24. send users logging in from wp-login.php directly to home page of site, rather than dashboard
  25. Warning: Cannot modify header information – headers already sent
  26. How to get login data (session) outside WordPress?
  27. wp-admin seems to be redirecting
  28. Add class to input form in login form
  29. Can’t Login to WordPress, No Data Received Error
  30. Allow access to a page for admins only
  31. Customizing the WordPress login form
  32. Restricting frontend acess based on user role otherwise redirect to login form
  33. how to restrict user login whenever if a user puts on hold by editing wp-login action?
  34. screwed-up my blog..what should I do
  35. How do I force “users must be registered and logged in” on subsites?
  36. deny IPs from wp-login using .htaccess
  37. Passing username to login screen
  38. Login error redirecting to wp-login page
  39. How can I find the login page? It was lost after moving the site
  40. How can I prevent my custom form from redirecting to wp-login?
  41. reset password link redirect to login page
  42. How do I replace “Username” in the WordPress login form?
  43. Custom Login iframe doesn’t work
  44. Password reset – Disabled for LDAP accounts
  45. How to Get Logged-in to “Remote WP Site” from my local script (in Same Browser)?
  46. Replace dash with space in username on login
  47. Autologin only working the second time
  48. replace wp-login.php login forms via a hook & use custom forms with wp-login form validation
  49. Show errors on custom login form [duplicate]
  50. Auto login between word press subdomain and a .net website
  51. Disabling standard registration login with username/email and password?
  52. How to change wordpress Log In text
  53. Why would the login page reload indefinitely?
  54. Redirect wp-login
  55. Creating custom login errors
  56. Is wp_login_form secure on a non secure page?
  57. Is the login encrypted before it is sent? If so how to do I encrypt it the same way?
  58. Why is wp-login trying to send an email?
  59. Form Action submit over https
  60. Is there anyway to get the inputted password string from the login form?
  61. Login and Forgot password in Lightbox
  62. Forcing frontend login with UI switch
  63. Can not login to wordpress site after resolving white screen of death
  64. Prevent display password on wp-login.php
  65. Change default login auth
  66. wordpress login without password just email address (NO 2 factor authentication with email)
  67. I can’t access my WordPress dashboard – shows Warning message [closed]
  68. WordPress SSL not working [closed]
  69. Where is the php file, that does the checks for login information?
  70. Access log “POST /wp-login.php HTTP/1.0” 400
  71. Cannot Get User id after login success in file wp_login.php
  72. Alert Message through email or phone(Message)
  73. Show errormessages on wrong username/password on custom loginform?
  74. Moving from one host to another – cannot access the dashboard
  75. Temporally disable password to login with empty password?
  76. How are all users now set to inactive?
  77. ERROR: Cookies are blocked due to unexpected output (no FTP access)
  78. Login error ” There has been a critical error on this website”
  79. woocommerce store login not working at first time
  80. Unable to login my wordpress website
  81. How do I change the language of the login page to Arabic?
  82. How do you implement a login feature on a WordPress site?
  83. Help! ERROR: Cookies are blocked due to unexpected output on attempting to login to resolve an issue with my site
  84. How to add custom authentication to wordpress login and register
  85. Problem in auto login after registration
  86. Login form does not store/remember/suggest users password
  87. Custom user roles are unable to login
  88. Using is_user_logged_in() to lock down whole site
  89. Check for $ _POST fields in a POST method form
  90. Styling WordPress login page – Can I change the markup on the login page?
  91. Special link for no automatic login (no username and no password)
  92. Can’t login to wordpress, got ERR_EMPTY_RESPONSE after a few minutes
  93. Modify wp-login.php Labels Conditionally Based On Referring URL
  94. Can’t login with any account – No error message shown
  95. WordPress Login & Register works in localhost but don’t work on server
  96. How to login to wordpress via Cpanel
  97. ERROR: Cookies are blocked due to unexpected output – ultimate solution
  98. Hide login page and use wp_login_form on ordinary pages
  99. Login screen keeps resetting?
  100. Make WordPress User Name the Email Address When Register
Categories login Tags errors, login, wp-login-form
How can I check if a user’s email exists in the database
Custom Post Type – Display Categories & Tags In Dashboard list

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress