You are here

function mailchimp_bio_nodeapi in Mailchimp 5.2

Same name and namespace in other branches
  1. 5 mailchimp_bio.module \mailchimp_bio_nodeapi()

Implementation of hook_nodeapi(). Allows update on bio change

File

./mailchimp_bio.module, line 7

Code

function mailchimp_bio_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if (function_exists('bio_get_type') && $node->type == bio_get_type()) {
    switch ($op) {
      case 'insert':
      case 'update':
        if (($q = _mailchimp_get_api_object()) && ($account = user_load(array(
          'uid' => $node->uid,
        )))) {
          foreach ((array) $q
            ->lists() as $key => $list) {
            if (_mailchimp_is_subscribed($list['id'], $account->mail, $q)) {
              $merge_vars = _mailchimp_load_user_list_mergevars($account->uid, $list['id'], $q
                ->listMergeVars($list['id']));
              _mailchimp_update_user($list, $account->mail, $merge_vars, $q);
            }
          }
        }
        break;
    }
  }
}