You are here

function mailchimp_get_memberinfo in Mailchimp 7.2

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

Get the MailChimp memberinfo for a given email address and list.

Results are cached in the cache_mailchimp_user bin which is cleared by the MC web hooks system when needed.

Parameters

string $list_id:

string $email:

bool $reset:

Return value

array memberinfo array.

4 calls to mailchimp_get_memberinfo()
mailchimp_is_subscribed in ./mailchimp.module
Check if the given email is subscribed to the given list.
mailchimp_lists_auth_newsletter_form in modules/mailchimp_lists/mailchimp_lists.module
Return a form element for a single newsletter.
mailchimp_set_memberinfo in ./mailchimp.module
Sets the member info in the cache.
_mailchimp_lists_build_update_mergevars in modules/mailchimp_lists/mailchimp_lists.module
Helper function for mailchimp_lists_user_sync().

File

./mailchimp.module, line 345
Mailchimp module.

Code

function mailchimp_get_memberinfo($list_id, $email, $reset = FALSE) {
  $cache = $reset ? NULL : cache_get($list_id . '-' . $email, 'cache_mailchimp_user');
  $memberinfo = array();

  // Return cached lists:
  if ($cache) {
    $memberinfo = $cache->data;
  }
  else {
    if ($q = mailchimp_get_api_object()) {
      $result = $q
        ->listMemberInfo($list_id, array(
        $email,
      ));
      if ($result['success']) {
        $memberinfo = reset($result['data']);
      }
    }
    cache_set($list_id . '-' . $email, $memberinfo, 'cache_mailchimp_user', CACHE_PERMANENT);
  }
  return $memberinfo;
}