Hello,
I am using the Kleo theme and have the home-register demo page set-up on my website for users to register and log in. For the last 4 days I have been trying to find codes / plugins which will re-direct all logged out users to /home-register so that way only logged in users can view the website.
Absolutely everything i’ve tried hasn’t worked.
I believe this may be a theme problem because lots of the codes I have tried create a “too many redirects error”. Here is the most recent code I tried which creates a redirection error:
COPY CODE
function wpsites_redirect_login_page() {
if ( ! is_user_logged_in() ) {
wp_redirect( 'http://mywebsite.com/home-register' );
exit();
}
}
add_action( 'template_redirect', 'wpsites_redirect_login_page