[Membership 2 Pro] Update MailChimp on Membership update

We are able to add a user to a MailChimp list and set a certain status when a member signs up in Membership 2 Pro.
But we are looking for a way to modify/change that status when there are changes to their subscription, e.g. they update their membership or unsubscribe.
Please take a look at this comment here for details - https://premium.wpmudev.org/forums/topic/in-addition#post-1407919. Is there a hook or snippet available to achieve this?
Please advice.

  • Panos
    • SLS

    Hi stripedrhino !

    As Ash mention, most of the status changes can be monitored in that hook. You mention the term unsubscribe which is a but blur to me. If by that you mean cancelled then you should be fine using that hook. However when a member cancels, the subscription is still active until expiration date. At that date the subscription status gets set to deactivated

    If what you want is the second, it is best to do this check through the cron status check, but it is quite complex. I have prepared a snippet that should change a "MMERGE" var when the subscription gets deactivated/expired. You can download it from here :

    After you download and unzip it, you can open the ms-mailchimp-segment-vars.php file with a text/code editor. You can set the "MMERGE" variables in this part of the file:

    self::$merge_fields =   [
                                            //'FNAME'         => 'Jack',
                                            //'LNAME'         => 'White',
                                            'MMERGE5'       => 'The new value'

    The above should set the "MMERGE5" segment to "The new value" for any subscription that it's new status is going to be set to expired/deactivated.

    Once you make your changes there, you can upload that file to the wp-content/mu-plugins folder.

    Now in order to test, you can create new test subscriptions and then from the admin set the start and end dates to the past (at least 2-3 days back though, cause of the grace period). Once you set that, you can go to the plugin's settings page and force run the status cron check by clicking on the link at the Check Membership Status changes footer.

    I would strongly suggest to first try this out on a staging or local site before moving it to the production site.

    Hope this helps!

    Kind regards!

  • stripedrhino
    • Site Builder, Child of Zeus

    Hello Panos
    Thanks for you replay..
    Actually i want to setup customer into mailchimp using membership 2 pro
    please look into screenshots

    In screenshot 1 : i will add a member and redirect to screenshot 2

    In screenshot 2 : i will select random multiple plans or single plan but it's not effect on mailchimp as per i want like in screenshot 3

    i have used this code in function.php for add selected subscription details in mailchimp add_filter( 'ms_addon_mailchimp_subscribe_user_merge_vars', function( $merge_vars, $member, $list_id ) {}
    but it's only work when i get user from search bar and update plans like in this below screenshot

    But it only work 1st time after this code not work ..
    so can you please help me to get out of this situation..

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.