By default, WordPress displays detailed error messages on the login screen whenever someone enters incorrect credentials. While this is helpful for legitimate users, it can also unintentionally reveal whether a specific username or email address is registered on your site
To make your site more secure, it’s a good idea to disable these login hints. In this post, we’ll show you how to hide login error details and replace them with a simple, generic message.
Solution: Hide login errors in WordPress
This snippet replaces the detailed WordPress login errors with a single, generic message that doesn’t reveal any hints, but just a generic error message.
add_filter('login_errors', 'ts_custom_login_error_message');
function ts_custom_login_error_message($error){
return 'Oops! Something went wrong. Please try again.';
}
// Add custom styling to WordPress login error messages
add_action('login_head', function() {
echo '<style>
.login #login_error {
background-color: #fff8e1;
border-left: 4px solid #ff9800;
color: #444;
font-size: 14px;
padding: 10px;
}
</style>';
});
Output
When someone enters an incorrect username or password, your WordPress login page shows a custom and neatly styled error message instead of the default WordPress ones.





