Need guidance on redirect after a member sign up for a membership in membership 2 pro.

Well, I am using gravity forms for my sign up and special configurations in the functions.php to auto assign a member and then auto login after registration. Everything is working correctly except my redirect after login. I have added this to the functions.php file:

* Auto login after registration.
*/
function pi_gravity_registration_autologin( $user_id, $user_config, $entry, $password ) {
$user = get_userdata( $user_id );
$user_login = $user->user_login;
$user_password = $password;

wp_signon( array(
'user_login' => $user_login,
'user_password' => $user_password,
'remember' => false
) );
}
add_filter( 'register', function( $link ) {
$link = sprintf(
'%2$s',
MS_Controller_Frontend::get_registration_url(),
__( 'Register', 'membership2' )
);

return $link;
}, 99, 1 );

  • Ivan

    Hi Phil !

    I'm not sure that I fully understand you.
    Where do you call pi_gravity_registration_autologin function? It seems if you say that auto login works - you can add redirect after that. It can look like

    wp_signon( array(
    'user_login' => $user_login,
    'user_password' => $user_password,
    'remember' => false
    ) );
    wp_redirect( 'YOUR_URL' );
    exit();

    Then you use 'register' filter but this filter uses for changing link to the Registration or Admin page. More info here And if you really want to change this link, you can change this code like this

    add_filter( 'register', function( $link ) {
    $link = sprintf(
    '<a href="%s">%s</a>',
    MS_Controller_Frontend::get_registration_url('register'),
    __( 'Register', 'membership2' )
    );
    
    return $link;
    }, 99, 1 )

    Best regards,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.