-
Author
-
April 10, 2016 at 01:01 #115454
monkeytoldme
ParticipantHello,
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 CODEfunction wpsites_redirect_login_page() { if ( ! is_user_logged_in() ) { wp_redirect( 'http://mywebsite.com/home-register' ); exit(); } } add_action( 'template_redirect', 'wpsites_redirect_login_pageApril 11, 2016 at 17:10 #115700Radu
ModeratorHi,
The snippet is ok
Make sure that you have default wordpress redirect option in wp-admin -> theme options -> miscellaneous -> Login redirect for Popup*
Let me know
Cheers
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionApril 11, 2016 at 23:02 #115847monkeytoldme
ParticipantHi,
This snippet is not working, even with the default wordpress redirect. I have been trying this for hours and I even contacted my host for help. Here is the exact code I’m using and if you go on 9feed.com you get a redirection error even though it brings you to /home-register.
function wpsites_redirect_login_page() {
if ( ! is_user_logged_in() ) {
wp_redirect( ‘http://9feed.com/home-register’ );
exit();
}
}
add_action( ‘template_redirect’, ‘wpsites_redirect_login_page’ );April 12, 2016 at 00:25 #115860monkeytoldme
ParticipantI figured this out, you can close the thread, thanks.
April 12, 2016 at 14:31 #115938Radu
ModeratorGreat
Have a nice week
Cheers
Radu
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.