Replace "The password you entered for the username admin is incorrect" with one message that doesn't confirm whether a username exists.
add_filter( 'login_errors', function ( string $error ): string {
global $errors;
$codes = $errors instanceof WP_Error ? $errors->get_error_codes() : [];
if ( array_intersect( $codes, [ 'invalid_username', 'invalid_email', 'incorrect_password' ] ) ) {
return '<strong>Error:</strong> The username or password is incorrect.';
}
return $error;
} );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
WordPress’s login errors are specific: one message for an unknown username and another for a wrong password. That tells attackers which usernames exist. This snippet replaces both with one generic message.
The login_errors filter receives the error HTML shown on wp-login.php. The snippet checks the error codes WordPress set and only replaces the username and password ones, so other messages, like “you are now logged out” or lockout notices, still appear.
On the login page, enter a username that doesn’t exist, then a real username with a wrong password. Both should show the same message.