I have a custom login form working properly on my home view. Nice. But what I want is when user try to view some page, be redirected to my home view instead of wp-login. Im trying to do this way:
add_action('template_redirect', 'redirect_to_login');
function redirect_to_login(){
if(!is_user_logged_in()){
wp_redirect(home_url()); exit;
}
}
It's not working. Browser says it has too many redirects. What can I do?
Thanks!