Skip to content

Instantly share code, notes, and snippets.

@jonbrockett
Created June 10, 2021 13:56
Show Gist options
  • Save jonbrockett/c56362ddbaed71dde0a7d8ef9bbc42d8 to your computer and use it in GitHub Desktop.
Save jonbrockett/c56362ddbaed71dde0a7d8ef9bbc42d8 to your computer and use it in GitHub Desktop.
Disable Author Pages
<?php
/**
* Disables the author pages
*
* This helps with security by preventing potential attackers
* from searching for login usernames
*/
function disable_author_page() {
global $wp_query;
if ( is_author() ) {
$wp_query->set_404();
status_header(404);
// Redirect to homepage
// wp_redirect(get_option('home'));
}
}
// Disable access to author page
add_action( 'template_redirect', 'disable_author_page' );
/** Disables the author pages to improve security */
require_once 'library/author-pages-disable.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment