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.

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:

// 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?

share|improve this question

closed as off-topic by Johannes Pille, ialocin, Wyck, Pat J, toscho Aug 16 at 0:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers 4

up vote 3 down vote accepted

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.

share|improve this answer

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;
}
share|improve this answer
    
"bp_get_activity_root_slug()" is the default value. I wanted to redirect them to home page after login. –  Towfiq Feb 24 '12 at 14:57

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.

share|improve this answer

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

share|improve this answer
    
This is not what I am trying to do actually. When a loggged in user tries to access the register page in buddypress, they are automatically redirected to "members direcotry". I want them to redirect to home page when they are trying to access the register page. Take a deep look at the code above and you will understand what I am trying to do here. –  Towfiq Jan 29 '12 at 6:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.