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


Try using this in your header:


if( ! is_user_logged_in() ) 
    wp_redirect( wp_login_url() );
  • +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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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