PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.5.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.5.0
5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 3.1.0 All 34 releases
double-opt-in / src / Events / Form / FormSubmittedEvent.php

FormSubmittedEvent.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.5.0, at src/Events/Form/FormSubmittedEvent.php

117 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Form Submitted Event
4 *
5 * @package Forge12\DoubleOptIn\Events\Form
6 * @since 4.0.0
7 */
8
9 namespace Forge12\DoubleOptIn\Events\Form;
10
11 use Forge12\DoubleOptIn\EventSystem\Event;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class FormSubmittedEvent
19 *
20 * @api
21 *
22 * Dispatched when a form is submitted before opt-in creation.
23 * Listeners can modify this event to skip opt-in creation.
24 * Covered by the Addon API semver policy as of Core API 4.3.0.
25 */
26 class FormSubmittedEvent extends Event {
27
28 private int $formId;
29 private string $formType;
30 private array $postedData;
31 private array $uploadedFiles;
32 private string $formUrl;
33 private bool $shouldCreateOptIn = true;
34 private ?string $skipReason = null;
35
36 /**
37 * Constructor.
38 *
39 * @param int $formId The form ID.
40 * @param string $formType The form type (cf7, avada, etc.).
41 * @param array $postedData The submitted form data.
42 * @param array $uploadedFiles The uploaded files.
43 * @param string $formUrl The URL where the form was submitted.
44 */
45 public function __construct(
46 int $formId,
47 string $formType,
48 array $postedData,
49 array $uploadedFiles,
50 string $formUrl
51 ) {
52 parent::__construct();
53 $this->formId = $formId;
54 $this->formType = $formType;
55 $this->postedData = $postedData;
56 $this->uploadedFiles = $uploadedFiles;
57 $this->formUrl = $formUrl;
58 }
59
60 /**
61 * {@inheritdoc}
62 */
63 public static function getWordPressHookName(): string {
64 return 'f12_cf7_doubleoptin_form_submitted';
65 }
66
67 public function getFormId(): int {
68 return $this->formId;
69 }
70
71 public function getFormType(): string {
72 return $this->formType;
73 }
74
75 public function getPostedData(): array {
76 return $this->postedData;
77 }
78
79 public function getUploadedFiles(): array {
80 return $this->uploadedFiles;
81 }
82
83 public function getFormUrl(): string {
84 return $this->formUrl;
85 }
86
87 /**
88 * Check if opt-in should be created.
89 *
90 * @return bool
91 */
92 public function shouldCreateOptIn(): bool {
93 return $this->shouldCreateOptIn;
94 }
95
96 /**
97 * Skip opt-in creation for this submission.
98 *
99 * @param string $reason The reason for skipping.
100 *
101 * @return void
102 */
103 public function skipOptInCreation( string $reason = '' ): void {
104 $this->shouldCreateOptIn = false;
105 $this->skipReason = $reason;
106 }
107
108 /**
109 * Get the reason for skipping.
110 *
111 * @return string|null
112 */
113 public function getSkipReason(): ?string {
114 return $this->skipReason;
115 }
116 }
117