Support » Themes and Templates » site closed unless logged in conditional

  • Resolved Robert Simpson

    (@rsimpson)


    Hi folks,

    I’m trying to add a conditional (if(is_user_logged_in() == FALSE) {}) which will show a closed template file instead of loading the rest of the site but having problems.

    If I add the conditional at the beginning of the header.php file it briefly appears to load the closed page before loading the site as normal.

    Does anybody know how I should be going about it?

    Cheers,
    Robert

Viewing 2 replies - 1 through 2 (of 2 total)
  • Equal Web Creative

    (@equalwebcreative)

    I think you will need to add it to the index.php and other template as necessary. This would be the formating of the PHP:

    <?php if(is_user_logged_in() ) { ?>
    //put all content here that you want to show logged in users
    <?php } else { ?>
    //put all content here that you want to show none logged in users
    <?php } ?>

    Thanks equal,

    I actually managed it before I checked back here.

    Here was my solution, I added this to the top of header.php before any other code in that file runs.

    $website_open = 0;
    
    if($website_open == FALSE) {
    	if(is_user_logged_in() == FALSE) {
    		include(TEMPLATEPATH . "/closed.php");
    		die();
    		}
    	}

    Cheers,
    Robert

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘site closed unless logged in conditional’ is closed to new replies.