WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] site closed unless logged in conditional (3 posts)

  1. Robert Simpson
    Member
    Posted 4 years ago #

    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

  2. Equal Web Creative
    Member
    Posted 4 years ago #

    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 } ?>
  3. Robert Simpson
    Member
    Posted 4 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic