Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i added the following code in the Header.php

<?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

1 Answer 1

Try using this in your header:

<?php 

if( ! is_user_logged_in() ) 
{
    wp_redirect( wp_login_url() );
    exit();
}
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
1  
ha! Blame my designer! It is similar lol. –  Cristian Feb 2 '12 at 17:05

Your Answer

 
discard

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.