Skip to content

Instantly share code, notes, and snippets.

@pjrvs pjrvs/how?
Last active Nov 7, 2017

What would you like to do?
here's the code to populate a mailchimp field with a wordpress variable:
add_filter( 'mailchimp_sync_subscriber_data', function( MC4WP_MailChimp_Subscriber $subscriber, $user ) {
$subscriber->merge_fields['MERGE6'] = AFF_ID_GOES_HERE;
return $subscriber;
}, 10, 2 );
here's the code to get the aff id:
if ( $affiliate = affiliate_wp()->affiliates->get_by( 'user_id', $user->ID ) ) {
// do stuff
how do i combine the two so i can push the affiliate ID to MERG6, only if it's not null (i.e. the user isn't an affiliate?
i'm trying to push the affiliate ID to mailchimp, thus letting me automate based on a changed/added merge field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.