<?php
if(is_user_logged_in()){
//do something
}else{
wp_redirect( wp_login_url() );
exit;
}
?>
So I try to do that, but get a header already sent error by Divi.
Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/themes/Divi/header.php:1) in /public_html/wp-includes/pluggable.php on line 1265
Is this a common error, any ideas to fix that?
This is caused by the page showing content before the PHP script is released. This can be a lot of things, if there's HTML being shown before the script I think it can do this. I've seen it happen before with trailing whitespace after closing a php tag too.