Site logo

Archived topic

Header hook

2 replies · Started by Dan on June 16, 2018

Viewing posts 1–3 of 3

Hi I added this hook to be added before the <head> section, but I get an error.
The code is added into th functions.php file
This is the hook (if the user is not logged in, show a temp page):

add_action( 'generate_before_header','ds_temp_page' ,1);  
function ds_temp_page() { ?> 
 <?php if(!is_user_logged_in()){wp_redirect( 'http://www.golancoalition.org/_index.html' ); exit;}?>

<?php }

The error I get is:

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\golanco\wp-includes\formatting.php:5103) in C:\xampp\htdocs\golanco\wp-includes\pluggable.php on line 1216

Any thoughts on why this is happening?

Thanks,
Dan

Testing in a live server did not produce this error, so it might be related to localhost.

Dan

This archived topic is closed to new replies.