You are here

function mailchimp_update_member_process in Mailchimp 7.3

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

Wrapper around Mailchimp_Lists::updateMember().

Return value

bool Success or failure.

See also

Mailchimp_Lists::updateMember()

1 call to mailchimp_update_member_process()
mailchimp_update_member in ./mailchimp.module
Update a members list subscription in real time or by adding to the queue.
2 string references to 'mailchimp_update_member_process'
mailchimp_update_local_cache in ./mailchimp.module
Updates the local cache for a user as though a queued request had been processed.
mailchimp_update_member in ./mailchimp.module
Update a members list subscription in real time or by adding to the queue.

File

./mailchimp.module, line 574
Mailchimp module.

Code

function mailchimp_update_member_process($list_id, $email, $merge_vars, $format, $replace_interests) {
  $result = FALSE;
  try {
    $mcapi = mailchimp_get_api_object();
    if (!$mcapi) {
      throw new MailchimpException('Cannot update member without MailChimp API. Check API key has been entered.');
    }
    $result = $mcapi->lists
      ->updateMember($list_id, array(
      'email' => $email,
    ), $merge_vars, $format, $replace_interests);
    if (isset($result['email'])) {
      watchdog('mailchimp', '@email was updated in list @list_id.', array(
        '@email' => $email,
        '@list' => $list_id,
      ), WATCHDOG_NOTICE);

      // Clear user cache:
      mailchimp_cache_clear_member($list_id, $email);
    }
    else {
      watchdog('mailchimp', 'A problem occurred updating @email on list @list.', array(
        '@email' => $email,
        '@list' => $list_id,
      ), WATCHDOG_WARNING);
    }
  } catch (Exception $e) {
    watchdog('mailchimp', 'An error occurred updating @email on list @list. "%message"', array(
      '@email' => $email,
      '@list' => $list_id,
      '%message' => $e
        ->getMessage(),
    ), WATCHDOG_ERROR);
  }
  return $result;
}