Jump to content

Redirect Non Logged In Users Except For Blog Posts


godrob

Recommended Posts

Hi Guys,

 

I'd be grateful if one of you could help me out here please?  Basically the code below redirects non-logged in users to my login page unless they access a page specified in the array below.  This all works just fine.  However, what I'd also like to achieve is for non-logged in users to be able to access any blog posts, too.  Any Wordpress guru's able to help me out here?

 

 

        <?php if(!is_user_logged_in() AND (!is_front_page() AND (!is_page( array (49, 57, 1796, 2017, 2951,686, 693, 675, 683, 689, 3063, 3477, 3649, 3989, 2576, 1773, 1784, 2700, 2706,    1791, 2709, 1778, 2703, 4115) ) ) ) ) {
		// wp_redirect('/index.php');
	       $redirect = home_url() . '/wp-login.php?redirect_to=' . urlencode( $_SERVER['REQUEST_URI'] );
	       wp_redirect( $redirect );
		exit;
	}
        ?>

 

Thanks for any help

 

Rob.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.