← Back to All Snippets

Block Author URL Enumeration Scans (?author=1)

⚡ Target: functions.php 🔒 Tested: WP 6.6+ / PHP 8.2+ 💻 Lang: PHP
PHP (functions.php)
add_action( 'template_redirect', function() {
    if ( is_author() && isset( $_GET['author'] ) ) {
        wp_safe_redirect( home_url(), 301 );
        exit;
    }
} );

Prevents automated bots from discovering valid WordPress administrator usernames by requesting /?author=1 query parameters.

← Back to All Snippets Explore Dev Tools →