1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/*
Plugin Name: WPSE Question #41699
Plugin URI: http://wordpress.stackexchange.com/questions/41699
Description: User needs to login first before accessing website (Author: Ajay Patel) 
Version: 0.1
Author: Brian Fegter
Author URI: http://wordpress.stackexchange.com/users/4793/brian-fegter
License: GPL2
*/

/* ------------------------- Actions --------------------------- */

add_action('wp', 'wpse_41699_wp', 0);
/**
 * Hooks into the `wp` action.
 * @link http://codex.wordpress.org/Plugin_API/Action_Reference/wp
*/
function wpse_41699_wp(){
    if(is_page('Login'))
        return;
    
    if(!is_user_logged_in()){
        $url = get_bloginfo('home').'/login';
        header('HTTP/1.1 403 Forbidden');
        header("Location: $url");
        exit;
    }
}
Droplr Logo

Shared With Droplr

Try it out for FREE today!

Learn More
Powered by Fusion