Buddypress register.php user redirect

In my buddypress I have set the register page as homepage. Now whenever a logged-in user tries to access the register page(homepage), they are redirected to Members directory. I want it to change to, home page. is there any way? I have tried changing the buddypress/bp-members/bp-members-signup.php file this way:

// If the user is logged in, redirect away from here
if ( is_user_logged_in() ) {
    if ( bp_is_component_front_page( 'register' ) )
        $redirect_to = bp_get_root_domain() . '/' . bp_get_members_root_slug();
    else
        $redirect_to = bp_get_root_domain();

    bp_core_redirect( apply_filters( 'bp_loggedin_register_page_redirect_to', $redirect_to ) );

    return;
}

To this:

Read More
// If the user is logged in, redirect away from here
if ( is_user_logged_in() ) {
    if ( bp_is_component_front_page( 'register' ) )
        $redirect_to = bp_get_root_domain() . '/';
    else
        $redirect_to = bp_get_root_domain();

    bp_core_redirect( apply_filters( 'bp_loggedin_register_page_redirect_to', $redirect_to ) );

    return;
}

I am getting this error:

The page isn’t redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Anyone knows how to fix this?

Related posts

Leave a Reply

4 comments

  1. Just a heads-up that you should be using the bp_loggedin_register_page_redirect_to filter to accomplish this, rather than modifying BuddyPress files (which will get overwritten on every upgrade).

    function bbg_bp_loggedin_register_page_redirect_to( $redirect_to ) {
        if ( bp_is_component_front_page( 'register' ) )
            $redirect_to = bp_get_root_domain() . '/home';
    
        return $redirect_to;
    }
    add_filter( 'bp_loggedin_register_page_redirect_to', 'bbg_bp_loggedin_register_page_redirect_to' );
    

    Put this in your theme’s functions.php or your bp-custom.php file http://codex.buddypress.org/extending-buddypress/bp-custom-php/. It’ll accomplish the same thing, but without touching BuddyPress itself.

  2. Couldn’t you use something like the walled garden technique. I’m not sure if it’s quite what you want, but it is customisable:

    function sh_walled_garden()
                {
                    global $bp;
                    if( bp_is_register_page() || bp_is_activation_page() || bp_is_page( BP_FORUMS_SLUG ) || bp_is_page( BP_GROUPS_SLUG ) )
                        return;
    
                    if( ! bp_is_blog_page() && ! is_user_logged_in() )
                        bp_core_redirect( bp_get_signup_page() );
                }
                add_action( 'bp_init', 'sh_walled_garden' );
    

    This hides members and activity from those not logged in but enables forums and groups for everyone รขย€ย“ see variation here. This goes in the buddypress bp-custom.php file and is discussed further here

    Somebody put a similar snippet here

  3. Ok. Found the issue. I was trying to redirect logged-in members from register page to homepage. And the homepage was set to register page. So, when a registered member tries to access the register page they are redirected back to homepage, which is set to the register page. So, there is a infinite loop of redirection. The browsers don’t allow this kind of redirection. So, I was getting this message:

    The page isn’t redirecting properly

    Firefox has detected that the server is redirecting the request for
    this address in a way that will never complete.

    So. instead of this:

        $redirect_to = bp_get_root_domain() . '/';
    else
        $redirect_to = bp_get_root_domain();
    

    I used this:

        $redirect_to = bp_get_root_domain() . '/home'; //A custom page.
    else
        $redirect_to = bp_get_root_domain();
    

    now it works fine. ๐Ÿ™‚ Problem solved.

  4. Work for me ๐Ÿ™‚

    // If the user is logged in, redirect away from here
    if ( is_user_logged_in() ) {
        if ( bp_is_component_front_page( 'register' ) )
            $redirect_to = bp_get_root_domain() . '/' . bp_get_activity_root_slug();
        else
            $redirect_to = bp_get_root_domain();
    
        bp_core_redirect( apply_filters( 'bp_loggedin_register_page_redirect_to', $redirect_to ) );
    
        return;
    }