Membership redirect not working correctly

I want to have users register as “basic” users first (for a free membership), then redirect them to the membership page to see the options for our premium plans and subscribe directly to a free trial and afterward get redirected to the homepage instead of the upgrade page again.

This is the code I am using:


add_action( ‘ms_controller_frontend_register_user_complete’, ‘ms_custom_after_registration’, 10, 3 );

function ms_custom_after_registration( $user, $request, $controller ) {

if ( !empty( $request ) ) {

$membership_id = $request;

if ( $membership_id == 2939 ) { //Select the id of the membership to check after registration

$custom_url = “;;

wp_safe_redirect( $custom_url );





Code above provided by one of the developers should handle the redirect. Although after a user clicks to sign up to a free membership, the redirect works, but a user is not subscribed to a free membership.