-
-
Save cartpauj/797ec5cf6e83d4725310b4231a743183 to your computer and use it in GitHub Desktop.
| <?php | |
| //hooks in to MemberPress $args array before sending new subscriber info to MailChimp | |
| function mepr_add_my_tags($args, $member) { | |
| $zip = get_user_meta($member->ID, 'mepr-address-zip', true); | |
| $country = get_user_meta($member->ID, 'mepr-address-country', true); | |
| if($zip) { | |
| $args['merge_fields']['MMERGE6'] = $zip; //YOU'LL NEED TO CHANGE MMERGEX TO MAP THEM TO YOUR OWN TAG VALUES | |
| } | |
| if($country) { | |
| $args['merge_fields']['MMERGE7'] = $country; //YOU'LL NEED TO CHANGE MMERGEX TO MAP THEM TO YOUR OWN TAG VALUES | |
| } | |
| return $args; | |
| } | |
| add_filter('mepr-mailchimptags-add-subscriber-args', 'mepr_add_my_tags', 11, 2); |
It should work for a dropdown field as long as it's not a multiselect field. I'm not sure if it would work for a checkbox field or not though.
That was a quick response, thanks!
Ok, I'll try it out and let you know.
Hi @cartpauj
I'm trying to use this. Is the filter still mepr-mailchimptags-add-subscriber-args ?
I'm trying to get it working but it sends no data and I'm wondering if that filter is still accurate.
Just sending one field (state) to Mailchimp
@murrinmedia Yes, the 3 filters available are:
$args = MeprHooks::apply_filters( 'mepr-mailchimptags-add-subscriber-args', $args, $user );
$args = MeprHooks::apply_filters('mepr-mailchimptags-add-tag-args', $args, $contact);
$args = MeprHooks::apply_filters('mepr-mailchimptags-remove-tag-args', $args, $contact);
Damn, Isn't working for me.
I can't tell if my code is incorrect or if the filter isn't even being used at all!
At the moment this data is only passed to Mailchimp on a member's initial signup. This is not a failing of this piece of code - it's how Memberpress functions. Any subsequent edits to any user data is not passed to Mailchimp. Is there a way to do something to this code, with the web hook that is triggered when a member updates their profile details, so that you could sync the custom field data with MailChimp?
Hi,
Thanks for this! Will it also work for dropdown and checkbox fields or just text fields?
Thanks,
Dom