Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Redirecting Register link

  • @antipole

    Participant

    Hi… a BuddyPress newbie here…
    I need users to be sent to an about registering page to give information before they go to the actual BuddyPress register form. I am trying to work out how to divert the register link to my own page.

    I have found a pointer to the source code but this does not correspond to what I see. I am looking in the bp plug-in edit window and I see no sub-folder bp-templates.

    My site is here and I am using WP 4.1.1; BuddyPress v2.2.2; bbPress 2.5.6-5643 and theme Attitude v1.4 from Theme Horse.

    I see several similar enquiries and it would be great if this were possible without end-users having to modify code.

    thanks

    PS I am using the (BuddyPress) Log in: Log in/out widget and it would be sufficient to divert the register link here, while leaving the WP register link unaffected so I can onward link to it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • @henrywright

    Moderator

    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.

    @antipole

    Participant

    @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.

    @antipole

    Participant

    @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

    @antipole

    Participant

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Redirecting Register link’ is closed to new replies.
Skip to toolbar