예제 #1
0
 public function process()
 {
     $errorMessage = $this->lexicon->getMsg('mc.subscription_failed');
     if (!$this->getCFGDef('apiKey')) {
         $this->addMessage($errorMessage);
         return false;
     }
     $MailChimp = new \DrewM\MailChimp\MailChimp($this->getCFGDef('apiKey'));
     $list_id = $this->getCFGDef('listId');
     if (!$list_id) {
         $this->addMessage($errorMessage);
         return false;
     }
     $MailChimp->post("lists/{$list_id}/members", array('email_address' => $this->getField('email'), 'merge_fields' => array('NAME' => $this->getField('name')), 'status' => 'pending'));
     if (!$MailChimp->getLastError()) {
         $this->addMessage($errorMessage);
     } else {
         $this->setFormStatus(true);
         $this->renderTpl = $this->getCFGDef('successTpl', $this->lexicon->getMsg('mc.default_successTpl'));
         return true;
     }
 }