scarstens
9/23/2013 - 2:39 AM

Force user to login before accessing the site (on WordPress)

Force user to login before accessing the site (on WordPress)

//force user login, regardless of post type
//UNLESS public is in the URL
add_action('parse_request', 'rr_login_redirect');
function rr_login_redirect() {
    global $wp;
    if(stristr($wp->request,'public/') || stristr($wp->request,'/public')){}
    elseif (!is_user_logged_in()) {
        auth_redirect();
    }
}