I'm making a member-only site that requires users to be logged in to use the site.
The homepage is publicly viewable. On the homepage, I'd like to put in a function to redirect users to a page inside the site if they are logged in.
The code I tried
<?php if (is_user_logged_in() ) {
wp_redirect ('dashboard' );
exit;
}
?>
Gives me a "headers already sent" error. The code is placed at the top of my php file.
What am I doing wrong?