Skip to content

Instantly share code, notes, and snippets.

@anthonybudd
Last active April 20, 2017 14:16
Show Gist options
  • Save anthonybudd/8f7b6c6c8788a42ae5deebeff2bb2f2c to your computer and use it in GitHub Desktop.
Save anthonybudd/8f7b6c6c8788a42ae5deebeff2bb2f2c to your computer and use it in GitHub Desktop.
<?php
// functions.php
function forceLogin(){
if(!is_user_logged_in()){
$redirect = TRUE;
foreach(['wp-admin', 'wp-login'] as $url) {
if(strpos($_SERVER['REQUEST_URI'], $url) !== FALSE){
$redirect = FALSE;
}
}
if($redirect){
auth_redirect();
}
}
}
if(defined('DEV') && DEV === TRUE){
forceLogin();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment