Change WordPress Login Error Messages for Security

Problem/Use Case:

Default error messages reveal whether the username or password is wrong — a security risk.

Snippet:

// Custom login error message
function custom_login_errors() {
    return 'Something went wrong. Please try again!';
}
add_filter('login_errors', 'custom_login_errors');

Explanation:

Replaces detailed error messages with a generic one.

Where to Place It:

In functions.php.

Bonus Tip:

You can also log failed login attempts for extra monitoring.

Ndifon Luke
Ndifon Luke

Ndifon Luke is the founder & owner of Uncle Luke Digitals—a web design, digital marketing freelancer based in Bamenda, Cameroon. He has over 6 years of expertise in digital marketing and is very passionate about working with clients in achieving their business objectives.