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

disable WP_error: authentication_failed

You can use the pluggable function wp_authenticate to override the core.

https://developer.wordpress.org/reference/functions/wp_authenticate/

Important caution: Test this code on a sandbox before deploying live!

function wp_authenticate($username, $password) {
    $username = sanitize_user($username);
    $password = trim($password);

    $user = apply_filters( 'authenticate', null, $username, $password );

    if ( $user == null ) {
        $user = new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: Invalid username or incorrect password.' ) );
    }

    $ignore_codes = array( 'authentication_failed' );

    if ( is_wp_error( $user ) && !in_array( $user->get_error_code(), $ignore_codes ) ) {
        do_action( 'wp_login_failed', $username );
    }

    return $user;
}
add_action( 'init', 'wp_authenticate' );

Related Posts:

  1. Logout/login redirect CSS issue
  2. How to display error messages using WP_Error class?
  3. Load .txt file for login_message in wp-login.php
  4. How to overwrite / extent wordpress function is_email
  5. How to change login labels
  6. Removing wp_login_viewport_meta
  7. Why There Is No “get content by ID” Function
  8. error at login page in wordpress
  9. Email Exists ERROR into Ajax registration form
  10. Show errormessages on wrong username/password on custom loginform?
  11. Login cookies blocked after customizing hashing method
  12. Unable to login after registration
  13. Re-style Login Form Whilst Keeping CSS Separate from Frontend CSS
  14. How to change form action of wp-login page with a function
  15. True email confirmation for registration (keeping unvalidated users from user table)
  16. Redirect after login to current URL
  17. wp_login_form display no styled form
  18. How to cache results of of get_available_post_statuses() function as it is causing a slow query on a website with over 1 million posts?
  19. Missing feature image link function
  20. What’s the difference between home_url() and site_url()
  21. Remove “Category:”, “Tag:”, “Author:” from the_archive_title
  22. get_template_directory_uri pointing to parent theme not child theme
  23. How to customize the_archive_title()?
  24. remove empty paragraphs from the_content?
  25. What is the “with_front” rewrite key?
  26. Why use if function_exists?
  27. How to override parent functions in child themes?
  28. wp_enqueue_script was called incorrectly
  29. Add multiple custom fields to the general settings page
  30. Ajax call always returns 0
  31. 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
  32. How long does a deprecated function live in core?
  33. Solution to render Shortcodes in Admin Editor
  34. How to add a data attribute to a WordPress menu item
  35. What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
  36. remove_action on after_setup_theme not working from child theme
  37. plugins_url vs plugin_dir_url
  38. Remove type attribute from script and style tags added by WordPress
  39. How to run a function every 5 minutes?
  40. Best way of passing PHP variable between partials?
  41. Upload Multiple Files With media_handle_upload
  42. How to display custom field in woocommerce orders in admin panel?
  43. Adding fields to the “Add New User” screen in the dashboard
  44. Issues with title-tag and document_title_parts
  45. How do I get the current edit page ID in the admin?
  46. How to check if a user exists by a given id
  47. Why isn’t is_page working when I put it in the functions.php file?
  48. Add tags to the section via functions.php
  49. Add image size if page template
  50. How to create a custom order status in woocommerce!
  51. Remove Actions/Filters added via Anonymous Functions
  52. Adding a second email address to a completed order in WooCommerce [closed]
  53. How to load parent_theme functions.php before child_theme?
  54. How to load scripts/styles specific for a page
  55. Programatically add options to “add new” custom field dropdown
  56. Is there any global functions.php file which works for any theme?
  57. Excluding iPad from wp_is_mobile
  58. When should you, and when should you not, use wp_list_pluck()?
  59. Get the ID of the page a menu item links to?
  60. Add container to nav_menu sub menu
  61. Difference between the_permalink() and get_permalink() function
  62. What’s the difference between WordPress random_int() and PHP built-in function random_int()?
  63. Child theme – Overriding ‘require_once’ in functions.php
  64. Link to user’s profile settings page?
  65. WordPress Enqueue for homepage only, functions.php, wp-framework
  66. get php variable from functions php and echo it in theme template files [closed]
  67. Get menu object from theme_location
  68. Is it ok to use a function to output the text domain name in a wordpress theme
  69. Displaying the number of updates available in the Admin area
  70. Trying to use add_action and do_action with parameters
  71. Use AJAX in shortcode
  72. Set JPEG compression for specific custom image sizes
  73. Can the new 4.8v text widget visual editor be removed?
  74. Prevent “main” WPMU site_url() being returned in functions
  75. Include files in child theme functions file
  76. Memorizing syntax
  77. Custom page with variables in url. Nice url with add_rewrite_rule
  78. Define page template in wp_insert_post
  79. Which WP functions do you need to use esc_html() or esc_url() on?
  80. Check if post is being published for the first time, or is an already published post being updated
  81. Display random categories on the front page (Finding and Editing Theme Functions)
  82. How to redirect to post if search results only returns one post
  83. remove links from images using functions.php
  84. Order posts (across the whole site) by metadata date
  85. Use author author display name in permalink structure for pages and posts
  86. Is it possible to rename a post format?
  87. Why does WordPress have private functions?
  88. Import WordPress XML File from Within Functions.php
  89. What is this code in my theme’s functions.php? if (isset($_REQUEST[‘action’]) && isset($_REQUEST[‘password’])
  90. Get list of years when posts have been published
  91. Add custom template page programmatically
  92. What is the correct MIME type for PSD (Photoshop)
  93. Redeclare a function in a child theme
  94. What is the difference between get_page_link and get_permalink functions?
  95. What’s the difference between admin_url() and get_admin_url() functions?
  96. Define custom Page Template without its own .php file
  97. Possible to search by author name with default WordPress search function?
  98. Does hooking into the same action multiple times drain memory?
  99. Cleaning up WordPress to improve performance?
  100. How to use the do_action () with parameter
Categories functions Tags core-modifications, functions, wp-error, wp-login-form
Foundation modal in wordpress php loop
How to run ajax in WordPress Post?

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