WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i added the following code in the Header.php

if ( !is_user_logged_in() ){    
<meta http-equiv="REFRESH" content="0;url=<?php wp_login_url(); ?>">
<?php exit;    
else {

to redirect a user who is not logged in to wp-login.php i didn't use wp_redirect as it was not working properly. code was working fine but some how today it is causing infinity loop. i have placed the code in header.php and i don't think wp-login.php calls header.php can some one tell me what's the problem here or any other suggestion thanks

share|improve this question

Try using this in your header:


if( ! is_user_logged_in() ) 
    wp_redirect( wp_login_url() );
share|improve this answer
+1 (not sure if for the right advice or for having a leica-style logo ;) – kaiser Feb 2 '12 at 17:04
ha! Blame my designer! It is similar lol. – Cristian Feb 2 '12 at 17:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.