Beispiel #1
0
 /**
  * Handler for wpcf7_submit hook.
  *
  * @param \WPCF7_ContactForm $contactform
  */
 public function submitForm($contactform)
 {
     if ($contactform->in_demo_mode()) {
         return;
     }
     $submission = \WPCF7_Submission::get_instance();
     $posted = $submission->get_posted_data();
     $groovehq_copy_email = $contactform->additional_setting("groovehq_copy_email");
     $groovehq_tags = $contactform->additional_setting("groovehq_tags");
     $groovehq_inbox = $contactform->additional_setting("groovehq_inbox");
     if (!$submission || !$posted) {
         return;
     }
     if (!isset($posted['your-email'])) {
         $sender = get_option('admin_email');
     } else {
         $sender = $posted['your-email'];
     }
     $ticket = array('state' => 'pending', 'to' => $sender, 'subject' => sprintf('%s: %s', $contactform->title(), $sender), 'from' => $this->getOption("inbox", "Inbox"), 'note' => true, 'body' => $this->getMessage($posted, $contactform->prop('form')));
     if (!is_null($groovehq_tags)) {
         $ticket = array_merge($ticket, array("tags" => explode(",", $groovehq_tags[0])));
     }
     if (!is_null($groovehq_inbox)) {
         $ticket["from"] = $groovehq_inbox[0];
     }
     if (!is_null($groovehq_copy_email)) {
         add_filter('wp_mail_content_type', array(&$this, "set_html_content_type"));
         wp_mail($groovehq_copy_email[0], $ticket["subject"], $ticket["body"]);
         remove_filter('wp_mail_content_type', array(&$this, "set_html_content_type"));
     }
     $res = $this->postAPI("/tickets", $ticket);
     if ($res && $this->getOption("to_pending", false)) {
         $this->setPendingTicket($res->ticket->number);
     }
 }