Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm running WordPress Multisite install with BuddyPress (WP 3.9, BP 1.9).

I'm using the code below to make the main website protected from not-logged-in users, and let them to visit only the landingpage, registration and activation pages. Registration and activation pages are native BuddyPress pages.

<?php
function shield() {
    if( !is_user_logged_in() ) { 
        if( !is_page( array( 'landingpage', 'registration', 'activation') ) ) {
            wp_redirect( 'landingpage' ); 
            exit(); 
        }
    }
}
add_filter('get_header','shield',1);
?>

The code works perfectly, except that it leads to redirection loop errors on registration and activation pages.

I think it's because BuddyPress has similar functions for this kind of pages for logged in users - to redirect them away from those two.

How to fix it? I would like to protect part of the site, but still allow registration.

PS: To prevent questions about login - it's on landingpage.

share|improve this question
    
WordPress 3.9? The current version is 3.8. –  Pat J Jan 10 at 22:19
    
Yeah, I live in the future. Misstyped. –  Borzd Jan 11 at 7:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.