[Membership 2 Pro] ? string after Membership 2 Pro user upgrades

When users join VideoBiker, they are added to a mailing list at SendinBlue. They receive automated emails relevant to the list they joined. SendinBlue can then move a user to a new mailing list based on a url that they view. We notice that when a user pays/upgrades their Membership 2 Pro membership, that the page they are redirected to has '?ms_relationship_id=' on the end. Is there any way that we can make this '? string' show their upgraded membership level? We are looking for a way to inform Sendinblue that a user has upgraded based on the url.

  • Ash
    • WordPress Hacker

    Hello Jez

    I am sorry I am a bit confused. Do you mean do you want the URL like this:


    Also, would you please let me know how you are adding user to SendinBlue? I mean which hook you are using and any sample code will help me to find a solution for you.

    Have a nice day!


  • Jez
    • VideoBiker

    Hi Ash - thanks for a quick response. It's a bit confusing I know (sorry). At the moment, site users first join a mailing list via SendinBlue. they are then prompted to open an account in the usual way via Membership 2 Pro. We will in time integrate this process to x1 form, but for now, it's a two stage process.

    Sendinblue tracks logged in users using an installed script & cookies.

    Via their 'workflows', sendinblue can then trigger list changes etc when a user lands on a specific url.

    So if I can identify what 'membership' a user has purchased based on the url redirect following purchase, I can trigger the required action in sendinblue...

    https://videobiker.co.uk/account/complete?ms_relationship_id=1234&new_membership_name=YYYY - would probably do the trick

    Appreciated if you can help.

  • Ash
    • WordPress Hacker

    Hello Jez

    Please try the following code:

    add_filter( 'ms_model_pages_redirect_to', function( $url, $page_type, $args ) {
    	$n_url = MS_Model_Pages::get_page_url( MS_Model_Pages::MS_PAGE_REG_COMPLETE );
    	$n_url = esc_url_raw( add_query_arg( $args, $n_url ) );
    	if( $n_url == $url ) {
    		$relationship = $args['ms_relationship_id'];
    		$subscription = MS_Factory::load( 'MS_Model_Relationship', $relationship );
    		$mid = $subscription->membership_id;
    		$membership = MS_Factory::load( 'MS_Model_Membership', $mid );
    		$url = $url . '&new_membership_name=' . $membership->name;
    	return $url;
    }, 99, 3 );

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.