Created
March 24, 2021 14:16
-
-
Save JarrydLong/7ec847602d97e4ffe67a75d264b6aa59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Creates a custom merge field in MailChimp. | |
| */ | |
| function my_pmpro_mailchimp_merge_fields( $merge_fields ) { | |
| $merge_fields[] = array( | |
| 'name' => 'GOAL', | |
| 'type' => 'text' | |
| ); | |
| return $merge_fields; | |
| } | |
| add_filter( 'pmpro_mailchimp_merge_fields', 'my_pmpro_mailchimp_merge_fields' ); | |
| /* | |
| * Populates the custom merge field in MailChimp | |
| */ | |
| function my_pmpro_mailchimp_listsubscribe_fields($fields, $user) { | |
| $user_id = $user->ID; | |
| $new_fields = array( | |
| "GOAL" => get_user_meta( $user_id, 'goal', true ), | |
| ); | |
| $fields = array_merge($fields, $new_fields); | |
| return $fields; | |
| } | |
| add_action('pmpro_mailchimp_listsubscribe_fields', 'my_pmpro_mailchimp_listsubscribe_fields', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment