godrob Posted July 10, 2012 Share Posted July 10, 2012 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. Link to comment https://forums.phpfreaks.com/topic/265468-redirect-non-logged-in-users-except-for-blog-posts/ Share on other sites More sharing options...
godrob Posted July 10, 2012 Author Share Posted July 10, 2012 Don't worry, I've worked it out... I simply added !is_single() Easy when you know how Link to comment https://forums.phpfreaks.com/topic/265468-redirect-non-logged-in-users-except-for-blog-posts/#findComment-1360500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.