Redirect author archive pages to the homepage and stop themes linking to them, which hides author usernames.
// Send /author/name/ and ?author=1 to the homepage.
add_action( 'template_redirect', function (): void {
if ( is_author() ) {
wp_safe_redirect( home_url( '/' ), 301 );
exit;
}
} );
// Make author links point to the homepage too.
add_filter( 'author_link', fn () => home_url( '/' ) );
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.
Author archives live at /author/username/, which publishes your login names. On single-author sites they also duplicate the blog. This snippet turns them off.
On template_redirect, any author archive, whether reached by pretty URL or ?author=1, is redirected to the homepage with a permanent 301. The author_link filter changes the links themes print next to posts so visitors and crawlers stop finding the archives.
?author= trick.Visit yoursite.com/?author=1. You should land on the homepage.