Skip to main content
Login Join
Snippet · PHP

Disable WordPress Login Error Details

Shared by Amit Dholiya · June 17, 2026

1 copy
27 views
1 upvote
Back to Snippets

By default, WordPress reveals whether the username or password is incorrect during login. This snippet hides those details and shows a generic error message.

Steps

  1. Open your WordPress theme functions.php file.
  2. Add the code below at the end of the file.
  3. Save the file.
  4. Test a failed login attempt.

Done — login errors will no longer reveal sensitive information

⚠️ This improves security by making it harder for attackers to determine valid usernames.

function custom_login_error_message() {
    return 'Invalid login credentials.';
}
add_filter('login_errors', 'custom_login_error_message');
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments