Hi,
I wanted to check if the user is logged into WordPress before showing a page. If user is logged in, redirect to page A, if not, redirect to page B.
Added a hook to wp_head with the following PHP code but I got an error that the header information cannot be modified…
<?php
if (is_user_logged_in()) {
header("Location: http://www.youtube.com");
} else {
header("Location: http://www.google.com");
}
?>
Got the following error code:
Warning: Cannot modify header information – headers already sent by (output started at /homepages/XXX/wp-content/themes/generatepress/header.php:12) in /homepages/XXX/wp-content/plugins/gp-premium/elements/class-hooks.php(215) : eval()’d code on line 5
Any help to get over this error is greatly appreciated!
Thanks!