Solved

WordPress - Auto Redirect Page when not logged in

Posted on 2013-05-13
3
426 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
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

809 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