WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

function shield() {
    if( !is_user_logged_in() ) { 
        if( !is_page( array( 'landingpage', 'registration', 'activation') ) ) {
            wp_redirect( 'landingpage' ); 

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 '14 at 22:19
Yeah, I live in the future. Misstyped. – Borzd Jan 11 '14 at 7:49

Your Answer


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

Browse other questions tagged or ask your own question.