Using this the header is already created on page load, I want all non-login user to redirect to the main website link.
[21-Feb-2017 21:20:40 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /mnt/stor1-wc2-dfw1/462870/524120/sandata.didit-dev.com/web/content/wp-content/themes/Joints Theme/header.php:3) in /mnt/stor1-wc2-dfw1/462870/524120/sandata.didit-dev.com/web/content/wp-includes/pluggable.php on line 1179
include_once(ABSPATH . 'wp-includes/pluggable.php');
function hook_diditdev(){
if(!is_user_logged_in()){
wp_redirect( get_option('live_site_link') ); exit();
}
}
add_action('wp_head', 'hook_diditdev');