Solved

WordPress - Auto Redirect Page when not logged in

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Drupal 5.x currently does not have a production-ready patch bundle to allow for split read & writes for a MySQL master/slave replication setup. After reading a open discussion/thread on the Drupal site (http://drupal.org/node/147160 (http://drupal.o…
Nowadays, it is so easy to get started with a website and all thanks to the Content Management Systems (CMS) like WordPress, Drupal, Joomla, and many others like them. However, if we talk about the reliability and ratings, WordPress definitely rules…
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. 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 :…
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now