/** * Get array of list objects this form subscribes to * * @return array */ public function get_lists() { if (is_null($this->lists)) { $this->lists = array(); foreach ($this->settings['lists'] as $list_id) { $this->lists[$list_id] = MC4WP_MailChimp_List::make($list_id); } } return $this->lists; }
/** * Fix field formatting for special fields like "birthday" and "address" */ public function auto_format_merge_vars() { $list = MC4WP_MailChimp_List::make($this->list_id); foreach ($this->merge_vars as $field_tag => $field_value) { $field_type = $list->get_field_type_by_tag($field_tag); switch ($field_type) { // birthday fields need to be MM/DD for the MailChimp API case 'birthday': $field_value = (string) date('m/d', strtotime($field_value)); break; // auto-format if addr1 is not set (ie: field was not broken up in multiple fields) // auto-format if addr1 is not set (ie: field was not broken up in multiple fields) case 'address': if (!isset($field_value['addr1'])) { // addr1, addr2, city, state, zip, country $address_pieces = explode(',', $field_value); // try to fill it.... this is a long shot $field_value = array('addr1' => $address_pieces[0], 'city' => isset($address_pieces[1]) ? $address_pieces[1] : '', 'state' => isset($address_pieces[2]) ? $address_pieces[2] : '', 'zip' => isset($address_pieces[3]) ? $address_pieces[3] : ''); } break; } // update field value $this->merge_vars[$field_tag] = $field_value; } }