You are here

function mailchimp_batch_update_members in Mailchimp 7.3

Same name and namespace in other branches
  1. 8 mailchimp.module \mailchimp_batch_update_members()
  2. 7.5 mailchimp.module \mailchimp_batch_update_members()
  3. 7.4 mailchimp.module \mailchimp_batch_update_members()
  4. 2.x mailchimp.module \mailchimp_batch_update_members()

Wrapper around MCAPI->lists->batch-subscribe.

$batch is an array where each element is an array formatted thus: 'email' => array('email' => 'example@example.com'), 'email_type' => 'html' or 'text', 'merge_vars' => array('MERGEKEY' => 'value', 'MERGEKEY2' => 'value2'),

1 call to mailchimp_batch_update_members()
mailchimp_lists_execute_mergevar_batch_update in modules/mailchimp_lists/mailchimp_lists.module
Batch processor for member mergevar updates to submit batches to MailChimp.

File

./mailchimp.module, line 641
Mailchimp module.

Code

function mailchimp_batch_update_members($list_id, $batch, $double_in = FALSE, $update_existing = FALSE, $replace_interests = TRUE) {
  $results = FALSE;
  try {
    $mcapi = mailchimp_get_api_object();
    if (!$mcapi) {
      throw new MailchimpException('Cannot batch subscribe to list without MailChimp API. Check API key has been entered.');
    }
    $results = $mcapi->lists
      ->batchSubscribe($list_id, $batch, $double_in, $update_existing, $replace_interests);
  } catch (Exception $e) {
    watchdog('mailchimp', 'An error occurred performing batch subscribe/update. "%message"', array(
      '%message' => $e
        ->getMessage(),
    ), WATCHDOG_ERROR);
  }
  return $results;
}