Solved

WordPress - Auto Redirect Page when not logged in

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Read about how to approach blogging and about ways to do it right. Stand out from the crowd and let your knowledge be consumed by a large audience. This article aims to explain how your blog should look like,  the most important things to do while b…
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…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now