Skip to content

Instantly share code, notes, and snippets.

@teolopez
Forked from daltonrooney/gist:1737771
Last active October 5, 2018 23:52
Show Gist options
  • Save teolopez/5891525 to your computer and use it in GitHub Desktop.
Save teolopez/5891525 to your computer and use it in GitHub Desktop.
Redirect all non-logged-in users to the login page (private site). Add to functions.php.
<?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