Created
December 15, 2014 16:46
-
-
Save thomasgriffin/e82ac5bb6d66734b6112 to your computer and use it in GitHub Desktop.
Filter data sent to Mailchimp (send IP address).
This file contains 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 | |
add_filter( 'optin_monster_pre_optin_mailchimp', 'tgm_om_custom_mailchimp_data', 10, 4 ); | |
/** | |
* Filter the data sent to Mailchimp. | |
* | |
* See here for more info on what is passed: https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php | |
* | |
* @param array $data Array of data being sent to Mailchimp. | |
* @param array $lead Array of lead data captured from the optin submission. | |
* @param string $list_id The unique list ID to subscribe the lead to. | |
* @param object $api The Mailchimp API connection object. | |
*/ | |
function tgm_om_custom_mailchimp_data( $data, $lead, $list_id, $api ) { | |
// Pass the IP address to Mailchimp as well. | |
$data['optin_ip'] = $_SERVER['REMOTE_ADDR']; | |
// Ensure to return the data after it has been modified. | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment