lets not process data if email confirmation is enabled.
authorKurund Jalmi <kurundjalmi@thirdsectordesign.org>
Fri, 11 Aug 2023 12:34:59 +0000 (13:34 +0100)
committerKurund Jalmi <kurundjalmi@thirdsectordesign.org>
Wed, 6 Dec 2023 00:23:33 +0000 (00:23 +0000)
ext/afform/core/Civi/Api4/Action/Afform/Submit.php

index 1bde2e3ff2ccf7da24e9bb9397737f297a588a91..b05c2b087b4de9e15feacaf6311decceafe4a985 100644 (file)
@@ -74,13 +74,24 @@ class Submit extends AbstractProcessor {
 
     // Save submission record
     if (!empty($this->_afform['create_submission'])) {
+      $status = 'Processed';
+      if (!empty($this->_afform['require_email_confirmation'])) {
+        $status = 'Pending';
+      }
+
       $submission = AfformSubmission::create(FALSE)
         ->addValue('contact_id', \CRM_Core_Session::getLoggedInContactID())
         ->addValue('afform_name', $this->name)
         ->addValue('data', $this->getValues())
+        ->addValue('status_id:name', $status)
         ->execute()->first();
     }
 
+    // let's not save the data in other CiviCRM table if email verification is needed.
+    if (!empty($this->_afform['require_email_confirmation'])) {
+      return [];
+    }
+
     // Call submit handlers
     $entityWeights = \Civi\Afform\Utils::getEntityWeights($this->_formDataModel->getEntities(), $entityValues);
     foreach ($entityWeights as $entityName) {