Skip to content

Instantly share code, notes, and snippets.

@geoclaps
Created September 19, 2018 14:46
Show Gist options
  • Save geoclaps/45453308140888ef98bf2e3dacaa29d0 to your computer and use it in GitHub Desktop.
Save geoclaps/45453308140888ef98bf2e3dacaa29d0 to your computer and use it in GitHub Desktop.
Disable access to Wordpress WP-admin
function blockusers_init() {
if ( is_admin() && ! current_user_can( ‘administrator’ ) && ! ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}
add_action( ‘init’, ‘blockusers_init’ );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment