Stop anyone registering or being created with usernames attackers try first, such as admin, administrator and root.
add_filter( 'illegal_user_logins', function ( array $logins ): array {
return array_merge( $logins, [
'admin',
'administrator',
'root',
'test',
'user',
'webmaster',
'support',
] );
} );
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.
Password-guessing bots start with usernames like “admin”. If no account has one of those names, every one of those attempts fails before the password even matters. This snippet stops those usernames being used for new accounts.
WordPress checks the illegal_user_logins list whenever a user is created or registers, including in wp-admin, on wp-login.php and through wp_insert_user(), which WooCommerce uses for customer accounts. Matching names are rejected with “Sorry, that username is not allowed.” The check isn’t case-sensitive.
Go to Users → Add New and try to create a user called “admin”. You should see “Sorry, that username is not allowed.”