Skip to content

Instantly share code, notes, and snippets.

@daltonrooney
Created February 4, 2012 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save daltonrooney/1737771 to your computer and use it in GitHub Desktop.
Save daltonrooney/1737771 to your computer and use it in GitHub Desktop.
WordPress function - redirect all non-logged-in users to the login page.
<?php
/* Redirect all non-logged-in users to the login page (private site). Add to functions.php. */
function admin_redirect() {
if ( !is_user_logged_in()) {
wp_redirect( home_url('/wp-admin/') );
exit;
}
}
add_action('get_header', 'admin_redirect');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment