Hi @antipole
This is the kind of thing you’ll want to do. The my_redirect()
function hooks to template_redirect
so bp_core_redirect()
executes at exactly the right time you need it to.
You’d put it in your theme’s functions.php file.
function my_redirect() {
// Conditions go here.
$location = 'http://example.com';
bp_core_redirect( $location );
}
add_action( 'template_redirect', 'my_redirect' );
Be careful when setting your conditions to avoid seeing the dreaded ‘redirect loop’ error.
Also, the Template Tag Reference will help you. For instance, bp_is_register_page()
will help you determine if the current page is the register page.
Hope this info helps.
@henrywright – thank you for responding
I set up a bp-custom.php file and am able to redirect as you suggest.
The condition I am using is
if ( bp_is_register_page()) {
This works in that any attempt to land on the register page gets redirected to my own pre-registration information page. But when I follow my ‘go ahead and register’ link, I get redirected back to my pre-registration information page. Since the re-direction happens as the registration page is about to load, I do not see how to get to registration when I need to.
I really need to divert the BP register links without stopping me going direct to the register page when the user is ready.
Any further advice would be much appreciated.
@henrywright… thinking about it further, I think my best approach would be to modify the (BuddyPress) Log in: Log in/out widget so that when a non-logged in user selected Register it linked to my own page. This would leave the real Register page unaffected and available for me to include as a link on my information page.
I have now found the widget code in the bp-core-widgets.php file. I took a copy into the bp-custom.php file, but I get the error message Fatal error: Cannot redeclare class BP_Core_Login_Widget.
I assume this original code is not checking if it has already been loaded. Not sure how I can modify this in a way that does not get lost on a BuddyPress update.
Can I trouble SKS for further guidance? thanks
I have a solution for this – although not particularly neat.
I took a copy of the BuddyPress Core Component Widgets and changed all occurrences of bp_core_register_widgets to, in my case, bp_ovni_core_register_widgets, and placed it in the bp-custom.php file. This gave me a new widget that I could place in the side bar instead of the standard (BuddyPress) Log In. This change seems necessary to avoid a re-registration error.
I then edited the action after <?php if ( bp_get_signup_allowed() ) : ?> to go to my information page instead of the register page. From that page I link to my actual registration page, where the register form is displayed.
It all seems to work for me.