trying to redirect with is_front_page() gives fatal error
-
Hello,
I have set a page as the home page of my site in settings -> reading.
I am trying to redirect users if they are logged and on the home page to a different page using this code:
add_action(‘init’, ‘redirect_if_user_logged_in’); add_action('template_redirect', 'redirect_if_user_logged_in'); function redirect_if_user_logged_in() { if ( is_front_page() && is_user_logged_in() ) { wp_redirect('(my url here)'); exit; } }
but my php won’t save because it will give a fatal error “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.”
I tried using is_home() instead but that doesn’t redirect. Can someone please tell me what I’m doing wrong?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘trying to redirect with is_front_page() gives fatal error’ is closed to new replies.