Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress registration page redirection loop errors after adding if(!is_user_lo


  • borzd
    Participant

    @borzd

    I’m running wpms install with buddypress (wp 3.9, из 1.9)

    I’m using code below to make main website protected from not logged in users, and let them to visit only 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);
    ?>

    Code works perfectly. Except that it ends 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 let registration.

    PS: To prevent questions about login – it’s on landingpage.

Viewing 5 replies - 1 through 5 (of 5 total)

  • borzd
    Participant

    @borzd

    Comon guys! No ideas?


    koendb
    Participant

    @koendb

    I don’t know the exact solution, but why don’t you check your if-statements first?
    change your code into:
    if( !is_page( array( ‘landingpage’, ‘registration’, ‘activation’)) ) {
    echo ‘Do redirect’;
    }

    and check if that message appears on the landing/registration page. That will probably happen and you’ll know you need to change that part. Maybe use the ID’s of those pages instead.


    borzd
    Participant

    @borzd

    @koendb

    Thanks a lot! That’s true what you suggested !is_page – doesn’t work.

    Even with ID.

    At the moment I don’t know how to change this part, but will look for it. Thanks one more time for you help and time!


    borzd
    Participant

    @borzd

    The funny part is:

    The code works (redirects properly) with any other page excluded. Except for this two buddypress pages…


    koendb
    Participant

    @koendb

    If is_page(page-id-of-registration-page) doesn’t return true on the registration page I wouldn’t know how to check for that page. Anybody else?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Buddypress registration page redirection loop errors after adding if(!is_user_lo’ is closed to new replies.
Skip to toolbar