// Redirect to login page in wordpress

add_action( 'init', 'ej_wp_user_logged_in' );
 
function ej_wp_user_logged_in() {
     if (!is_user_logged_in()) {
          wp_redirect( wp_login_url() ); exit;
     }
}