← Back to All Snippets

Hide Generic WordPress Login Error Hints to Prevent Username Probing

⚡ Target: functions.php 🔒 Tested: WP 6.6+ / PHP 8.2+ 💻 Lang: PHP
PHP (functions.php)
add_filter( 'login_errors', function( $error ) {
    return '<strong>Error:</strong> Invalid login credentials. Please verify your details and try again.';
} );

Replaces informative login error messages (‘Invalid username’ vs ‘Incorrect password’) with a generic notice to prevent credential enumeration.

← Back to All Snippets Explore Dev Tools →