[Membership 2 Pro] Membership 2 Pro -> MailChimp

This is more of a question... can Membership 2 Pro send user data and which subscription they are on to MailChimp?

  • James Morris

    Hello sccr410,

    I hope you are well today.

    Out of the box, in the settings, no this is not possible. However, with a bit of custom coding using the Membership 2 Pro API and the MailChimp List fields and *|MERGE|* tags yes this is possible.

    While custom development is outside the scope of normal support, I'm going to ping our SLS Team (code experts) to get their valuable feedback on this. An update will be posted here as soon as more information is available. Thank you for your patience while we look into this further.

    Best regards,

    James Morris

  • Panos

    Hi there sccr410 ,

    You can use the
    ms_addon_mailchimp_subscribe_user_merge_vars
    for adding new vars as in the following example:

    add_filter( 'ms_addon_mailchimp_subscribe_user_merge_vars', function( $merge_vars, $member, $list_id ){
    
    	$membership_id = null;
    	if( isset( $_REQUEST[ 'membership_id' ] ) ){
    		$membership_id = intval( $_REQUEST[ 'membership_id' ] );
    	}
    	elseif( isse( $_REQUEST[ 'membership' ] ) ){
    		$membership_id = intval( $_REQUEST[ 'membership' ] );
    	}
    
    	if( ! is_null( $membership_id ) ){
    		$membership = MS_Factory::load( 'MS_Model_Membership', intval( $membership_id ) );
    		$merge_vars['MEMBERSHIP'] = $membership->name;
    	}
    
    	if( isset( $_REQUEST[ 'ms_relationship_id' ] ) ){
    		$merge_vars['SUBID'] = $_REQUEST[ 'ms_relationship_id' ];
    	}
    
    	return $merge_vars;
    
    }, 10, 3 );

    You can add the above snippet in a mu-plugin and try it out.

    Hope this helps!

    Kind regards!