function get_mailchimp_lists_string($email) { $lists = array(); foreach (get_mailchimp_lists($email) as $list) { $lists[] = $list['name']; } return implode(', ', $lists); }
function update_mailchimp_subscriptions($email, $first_name, $last_name, $mailing_list_ids) { $this->load->library('mcapi', array('apikey' => $this->Location->get_info_for_key('mailchimp_api_key'))); $mailing_list_ids = $mailing_list_ids === FALSE ? array() : $mailing_list_ids; $current_lists = get_mailchimp_lists($email); foreach ($current_lists as $list) { //If a list we are currently subscribed to is not in the updated list, unsubscribe if (!in_array($list['id'], $mailing_list_ids)) { $this->mcapi->listUnsubscribe($list['id'], $email, false, false, false); } } foreach ($mailing_list_ids as $list) { $this->mcapi->listSubscribe($list, $email, array('FNAME' => $first_name, 'LNAME' => $last_name), 'html', false, true, false, false); } }