Solved

WordPress - Auto Redirect Page when not logged in

Posted on 2013-05-13
3
438 Views
Last Modified: 2013-08-09
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?
0
Comment
Question by:JustinBMak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39163573
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

0
 

Author Comment

by:JustinBMak
ID: 39164345
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
0
 
LVL 21

Accepted Solution

by:
Julian Matz earned 500 total points
ID: 39164762
Which pages would you like to have refreshed? If you put the code into your theme's header.php template, it should work for all public pages.

<?php if ( ! is_user_logged_in() && ! is_admin() ) : ?>
<meta http-equiv="refresh" content="5;url=pagename.html">
<?php endif; ?>

Open in new window

0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am not an expert on blogging.  So, my first port of call was to read a book, 'Publish and Prosper – Blogging for your Business' (http://www.amazon.com/Publish-Prosper-Blogging-Your-Business/dp/0321395387) by DL Byron and Steve Broback.  This gives…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question