• Resolved godrob

    (@godrob)


    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.

    <?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;
    		}
            ?>

    Any help appreciated

    Thanks
    Rob

Viewing 1 replies (of 1 total)
  • Thread Starter godrob

    (@godrob)

    Don’t worry, I’ve worked it out…

    I simply added !is_single()

    Easy when you know how ??

Viewing 1 replies (of 1 total)
  • The topic ‘Redirect Non Logged In Users Except For Blog Posts’ is closed to new replies.