Link to home
Create AccountLog in
Avatar of JustinBMak
JustinBMak

asked on

WordPress - Auto Redirect Page when not logged in

Folks:

I am building this internal company website and I am trying to get it where when they viewing the website it auto refreshes after say 10 seconds or so. But where the problem is when they are logged in as a Administrator and editing the page it also does the refresh because the only way I know how to use it is the standard <meta http-equiv="refresh" content="5;url=pagename.html">. So it makes it almost impossible to do any edits in the Admin portal on a site because it keeps refreshing. Is there any plug-in or code that anyone knows of that will do the redirect when NOT loading the admin/content page?
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

You need to use is_user_logged_in() if you want to distinguish between logged in and logged out states.

if ( !is_user_logged_in() ) {
   <meta http-equiv="refresh" content="5;url=pagename.html"> 
}

Open in new window

Avatar of JustinBMak
JustinBMak

ASKER

And where do I put this snip of code? I put it in the on the page itself, but Wordpress breaks it out in the <p> sniplets (see attached image)

P.S. I am not a Wordpress expert at all
WP-HTML-Error.PNG
ASKER CERTIFIED SOLUTION
Avatar of Julian Matz
Julian Matz
Flag of Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account