
What Is User Enumeration in WordPress (and Why It Matters)?
User enumeration happens when attackers can figure out the usernames of people who have access to your WordPress dashboard, especially admin accounts.
Once they know the username, half of the login equation is solved. Now they only need the password, making brute-force attacks much easier.
For example, if someone knows your admin username is “sajidul,” they can focus all login attempts on that user instead of guessing names first.
This is why preventing username exposure is a critical step in WordPress security.
How Attackers Perform User Enumeration
Attackers typically rely on small WordPress behaviors and predictable URL patterns to collect usernames. Here are the most common methods, explained simply:
1. Author Archives (/?author=1)
WordPress automatically creates author pages for each user who has written a post. These pages often reveal the username directly in the URL.
For example:
yourwebsite.com/?author=1
might redirect to:yourwebsite.com/author/admin/
This gives attackers instant confirmation of a valid username without hacking anything.
2. Login Error Messages
When you enter a wrong username or password on the login page, WordPress may show different messages, such as:
- “Invalid username”
- “Incorrect password”
Even though this seems harmless, it reveals whether the username exists, helping hackers narrow down their targets.
3. REST API Exposure
The WordPress REST API endpoint /wp-json/wp/v2/users sometimes exposes user information, including usernames.
This endpoint was designed for developers, but if left unrestricted, it becomes a useful tool for attackers.
4. XML-RPC Multicall Attacks
XML-RPC allows automated systems to send multiple commands at once. Hackers use this to send hundreds of login attempts in a single request.
If usernames are already known, XML-RPC becomes extremely powerful for brute-force attacks.
How to Prevent User Enumeration in WordPress
Below are practical methods to protect your site, along with explanations for each.
1. Disable Author Archives
Most user enumeration happens through author archives. If your site doesn’t use author pages, it’s best to disable them entirely.
This prevents WordPress from showing URLs that include usernames, blocking a major source of leaks.
add_action('template_redirect', function() {
if (is_author()) {
wp_redirect(home_url());
exit;
}
});
2. Redirect /?author=1 Requests
Even if author archives are disabled, /?author=1 URLs can still reveal usernames unless properly blocked.
This redirect stops attackers from using this trick.
add_filter('redirect_canonical', function($redirect_url, $requested_url) {
if (preg_match('/\?author=\d+/i', $requested_url)) {
return home_url();
}
return $redirect_url;
}, 10, 2);
3. Hide Detailed Login Error Messages
Customizing the login error message prevents attackers from confirming whether the username exists.
It keeps both invalid username and invalid password errors generic.
add_filter('login_errors', function() {
return 'Invalid login credentials.';
});
This way, attackers get no extra information.
4. Disable User Endpoint in REST API
If your site does not need public access to user data through the REST API, you should disable the user endpoint.
This is one of the strongest protections against username exposure.
add_filter('rest_endpoints', function($endpoints) {
if (isset($endpoints['/wp/v2/users'])) {
unset($endpoints['/wp/v2/users']);
}
if (isset($endpoints['/wp/v2/users/(?P<id>[\d]+)'])) {
unset($endpoints['/wp/v2/users/(?P<id>[\d]+)']);
}
return $endpoints;
});
5. Disable XML-RPC (Especially If You Don’t Use It)
Most modern WordPress sites don’t need XML-RPC. Disabling it closes a major door used for brute-force attacks.
add_filter('xmlrpc_enabled', '__return_false');
If you rely on apps like Jetpack or remote posting, you can limit it instead of fully disabling.
6. Use a Security Plugin (Easy, Non-Technical Option)
If you prefer not to deal with code, a security plugin or a dedicated plugin can protect your site in one click. Plugins like:
- Stop User Enumeration
- Wordfence
- iThemes Security
- All-In-One WP Security
These plugins block enumeration attempts automatically, log suspicious activity, and alert you in real time.
7. Avoid Using Common Usernames Like “admin”
Many website owners still use “admin” as their main username — and this makes attacks incredibly easy.
Creating a unique username makes you harder to target and significantly increases security.
8. Enable Rate Limiting for Login Attempts
Rate limiting stops attackers from trying unlimited login guesses.
You can implement this using:
- Wordfence
- Cloudflare Security
- Server-level rules
- Hosting firewalls
This helps block bot attacks before they reach WordPress.
Conclusion
User enumeration might feel like a small issue, but it opens the door to serious hacking attempts. Once attackers know your usernames, breaking in becomes much easier.
Fortunately, blocking user enumeration is simple.
By disabling author archives, hiding login errors, securing your REST API, and adding basic protections like rate limiting, you make your WordPress website significantly safer.
About Sajidul Islam
WordPress developer passionate about creating beautiful, functional websites.
View all posts