function AutoResponderMailChimp($that, $ar, $wpm_id, $email, $unsub = false)
 {
     $listID = $ar['mcID'][$wpm_id];
     // get the list ID of the Membership Level
     $mcAPI = $ar['mcapi'];
     // get the MailChimp API
     $WishlistAPIQueueInstance = new WishlistAPIQueue();
     $WLM_AUTORESPONDER_MAILCHIMP_INIT = new WLM_AUTORESPONDER_MAILCHIMP_INIT();
     if ($listID) {
         //$listID should not be empty
         list($fName, $lName) = explode(" ", $that->ARSender['name'], 2);
         //split the name into First and Last Name
         $emailAddress = $that->ARSender['email'];
         $data = false;
         if ($unsub) {
             // if the Unsubscribe
             $mcOnRemCan = isset($ar['mcOnRemCan'][$wpm_id]) ? $ar['mcOnRemCan'][$wpm_id] : "";
             if ($mcOnRemCan == "unsub") {
                 //$res = $this->mcListUnsubscribe($mcAPI, $listID, $emailAddress, true);
                 $data = array("apikey" => $mcAPI, "action" => "unsubscribe", "listID" => $listID, "email" => $emailAddress, "delete_member" => true);
             } elseif ($mcOnRemCan == "move" || $mcOnRemCan == "add") {
                 $gp = $ar['mcRCGp'][$wpm_id];
                 $gping = $ar['mcRCGping'][$wpm_id];
                 $groupings = array();
                 if ($gp != "" && $gping != "") {
                     $groupings = array(array('name' => $gp, 'groups' => $gping));
                 }
                 $replace_interests = $mcOnRemCan == "move" ? true : false;
                 #add name or else this will still fail
                 $merge_vars = array('FNAME' => $fName, 'LNAME' => $lName, 'NAME' => "{$fName} {$lName}", 'GROUPINGS' => $groupings);
                 // populate the merger vars for MailChimp
                 //$res = $this->mcListSubscribe($mcAPI, $listID, $emailAddress, $merge_vars, true, true, $replace_interests);
                 $data = array("apikey" => $mcAPI, "action" => "subscribe", "listID" => $listID, "email" => $emailAddress, "mergevars" => $merge_vars, "optin" => true, "update_existing" => true, "replace_interests" => $replace_interests);
             }
         } else {
             //else Subscribe
             $gp = $ar['mcGp'][$wpm_id];
             $gping = $ar['mcGping'][$wpm_id];
             $groupings = array();
             if ($gp != "") {
                 $groupings = array(array('name' => $gp, 'groups' => $gping));
             }
             $optin = $ar['optin'];
             // get the MailChimp API
             $optin = $optin == 1 ? false : true;
             #add name or else this will still fail
             $merge_vars = array('FNAME' => $fName, 'LNAME' => $lName, 'NAME' => "{$fName} {$lName}", 'GROUPINGS' => $groupings);
             // populate the merger vars for MailChimp
             //$res = $this->mcListSubscribe($mcAPI, $listID, $emailAddress, $merge_vars, $optin, true, false);
             $data = array("apikey" => $mcAPI, "action" => "subscribe", "listID" => $listID, "email" => $emailAddress, "mergevars" => $merge_vars, "optin" => $optin, "update_existing" => 1, "replace_interests" => false);
         }
         if ($data) {
             $qname = "mailchimp_" . time();
             $data = maybe_serialize($data);
             $WishlistAPIQueueInstance->add_queue($qname, $data, "For Queueing");
             $WLM_AUTORESPONDER_MAILCHIMP_INIT->mcProcessQueue();
         }
     }
 }
 Calling program : integration.autoresponder.php
 Logic Flow:
 1. integration.autoresponder.php displays this script (integration.autoresponder.mailchimp.php)
 and displays current or default settings
 2. on user update, this script submits value to integration.autoresponder.php, which in turn save the value
 3. after saving the values, integration.autoresponder.php call this script again with $wpm_levels contains the membership levels and $data contains the MailChimp Integration settings for each membership level.
*/
$__index__ = 'mailchimp';
$__ar_options__[$__index__] = 'MailChimp';
$__ar_videotutorial__[$__index__] = wlm_video_tutorial('integration', 'ar', $__index__);
if ($data['ARProvider'] == $__index__) {
    if ($__INTERFACE__) {
        if (class_exists('WLM_AUTORESPONDER_MAILCHIMP_INIT')) {
            $api_key = $data[$__index__]['mcapi'];
            if ($api_key != "") {
                $WLM_AUTORESPONDER_MAILCHIMP_INIT = new WLM_AUTORESPONDER_MAILCHIMP_INIT();
                $lists = $WLM_AUTORESPONDER_MAILCHIMP_INIT->mcCallServer("lists", array("limit" => 100), $api_key);
                if (!isset($lists['error']) && $lists['total'] > 0) {
                    $lists = $lists['data'];
                } else {
                    $lists = array();
                }
            }
        }
        ?>
		<script type="text/javascript">
			jQuery(document).ready(function(){
				jQuery('.wlmmcAction').change(function(){
					var selected = jQuery(this).val();
					if(selected == "unsub" || selected == ""){
						jQuery(this).parent().find("input").val("");