• Resolved alex20231

    (@alex20231)


    Hi,

    I am new to this, so probably a silly question. I want to redirect to the page a user was on before registration. I found this code

    add_action( 'user_registration_before_customer_login_form', 'ur_set_redirect_url' );
    function ur_set_redirect_url() {
    if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
    set_transient( 'originalLoginRefererURL', $_SERVER['HTTP_REFERER'], 60 * 60 * 24 );
    }
    }
    add_filter( 'user_registration_login_redirect', 'ur_redirect_back', 10, 2 );
    function ur_redirect_back( $redirect, $user ) {
    if ( true === ( $redirect_url = get_transient( 'originalLoginRefererURL' ) ) ) {
    delete_transient( 'originalLoginRefererURL' );
    return $redirect_url;
    }
    return $redirect_url;
    }

    Where do I add this code for this to work?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Where do I add the code for redirect after registration?’ is closed to new replies.