Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Created December 15, 2014 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thomasgriffin/e82ac5bb6d66734b6112 to your computer and use it in GitHub Desktop.
Save thomasgriffin/e82ac5bb6d66734b6112 to your computer and use it in GitHub Desktop.
Filter data sent to Mailchimp (send IP address).
<?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