Skip to content

Instantly share code, notes, and snippets.

@gyrus
Created July 21, 2012 13:25
Show Gist options
  • Save gyrus/3155823 to your computer and use it in GitHub Desktop.
Save gyrus/3155823 to your computer and use it in GitHub Desktop.
Force WordPress login
<?php
/**
* Force WordPress login
*/
add_action( 'init', 'pilau_force_login' );
function pilau_force_login() {
if ( ! is_user_logged_in() && $_SERVER["SCRIPT_NAME"] != '/wp-login.php' ) {
wp_redirect( wp_login_url() );
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment