0

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

1 Answer 1

3

Try using this in your header:

<?php 

if( ! is_user_logged_in() ) 
{
    wp_redirect( wp_login_url() );
    exit();
}
2
  • +1 (not sure if for the right advice or for having a leica-style logo ;)
    – kaiser
    Commented Feb 2, 2012 at 17:04
  • 1
    ha! Blame my designer! It is similar lol.
    – Cristian
    Commented Feb 2, 2012 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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