Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to redirect after registration?


  • johnywhy
    Participant

    @johnywhy

    hi

    the post linked below explains how, but i don’t know where to put the code.

    where does this code go? i don’t want it to break if i update wordpress, or change or update my theme.

    <?php
    function bp_redirect($user) {
        $redirect_url = 'http://www.mysite.com/yeah';
        bp_core_redirect($redirect_url);
    }
    
    add_action('bp_core_signup_user', 'bp_redirect', 100, 1);
    ?>

    http://wordpress.stackexchange.com/a/18302/88260

    thx!

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

  • shanebp
    Moderator

    @shanebp

    You can put it in your theme or child-theme functions.php or in bp-custom.php.


    johnywhy
    Participant

    @johnywhy

    Fantastic. Thx!

    How/when does WP execute it?


    johnywhy
    Participant

    @johnywhy

    or, if this was a plugin, where would i place this code?

    activate_redirect_after_register
    or
    run_redirect_after_register
    ?

    i’m guessing this part should go in the ‘activate’ function
    add_action(‘bp_core_signup_user’, ‘bp_redirect’, 100, 1);

    and everything should go in the ‘run’ section. Correct?

    thx!


    johnywhy
    Participant

    @johnywhy

    Update: i put the code into bp-custom.php. Not quite working.

    It is getting redirected– but i’m not getting the page i entered into bp-custom.php. I’m getting redirected to the WP login screen.

    So the code is doing something. But not redirecting right.

    Any ideas?

    (you can forget about plugin question, just want to make the code work).

    thx!


    Henry Wright
    Moderator

    @henrywright

    Can you paste the code you’re using here?


    johnywhy
    Participant

    @johnywhy

    i’m trying to post the code, but i cannot see my posts here


    johnywhy
    Participant

    @johnywhy

    will try to post this bit by bit.

    this code is in “plugins\my-redirect.php”. The plugin is activated.


    johnywhy
    Participant

    @johnywhy

    <?php
    /*
    Plugin Name:       Redirect After Register
    Plugin URI:        http://laptopacademy.net
    Description:       Redirect after user registration. 
    Version:           1.0.0
    Author:            John Weiss
    Author URI:        http://laptopacademy.net/wordpress/instructor
    License:           GPL-2.0+
    License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
    Text Domain:       redirect-after-register
    Domain Path:       /languages
    */

    johnywhy
    Participant

    @johnywhy

    function bp_redirect($user) {
        $redirect_url = 'http://www.mysite.com/yeah';
        bp_core_redirect($redirect_url);
    }
    
    add_action('bp_core_signup_user', 'bp_redirect', 100, 1);
    
    ?>

    johnywhy
    Participant

    @johnywhy

    this thread says bp_core_signup_user does not work:
    https://wordpress.org/support/topic/how-to-hook-into-add-new-member-in-buddypress

    the weird thing is, it’s doing something (because it goes to the login page with the hack, and to the activation page without the hack).

    So i think bp_core_signup_user is working. The issue appears to be bp_core_redirect.

    Paul Gibbs, Keymaster, suggests bp_core_redirect might get called in the wrong place– “too high up in the stack”. The OP also mentions that wp_redirect works, and in fact wp_redirect works for me.

    So, unless there’s some special reason why i should not use wp_redirect, that’s my fix.

    why does bp_core_redirect even exist, if wp_redirect is available? I assume it has some special function that wp_redirect cannot do. right?

    any ideas why it doesn’t work in this scenario? Maybe something wrong with those parameters i’m passing it, 100 and 1? What are those params? Where can i find documentation for bp_core_redirect? can’t find…..

    many thx


    johnywhy
    Participant

    @johnywhy

    update, i tried bp_core_redirect without any params– still does not work. I suspect maybe it only works when a user is logged in?


    johnywhy
    Participant

    @johnywhy

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to redirect after registration?’ is closed to new replies.
Skip to toolbar