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 / Lifecycle / OptInConfirmedEvent.php

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

114 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OptIn Confirmed Event
4 *
5 * @package Forge12\DoubleOptIn\Events\Lifecycle
6 * @since 4.0.0
7 */
8
9 namespace Forge12\DoubleOptIn\Events\Lifecycle;
10
11 use Forge12\DoubleOptIn\EventSystem\Event;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class OptInConfirmedEvent
19 *
20 * @api
21 *
22 * Dispatched when an opt-in is confirmed via the confirmation link.
23 * Covered by the Addon API semver policy as of Core API 4.3.0.
24 */
25 class OptInConfirmedEvent extends Event {
26
27 private int $optInId;
28 private string $hash;
29 private string $email;
30 private string $confirmedIp;
31 private int $formId;
32 private array $formData;
33
34 /**
35 * Constructor.
36 *
37 * @param int $optInId The opt-in record ID.
38 * @param string $hash The opt-in hash.
39 * @param string $email The subscriber email.
40 * @param string $confirmedIp The IP address that confirmed.
41 * @param int $formId The original form ID.
42 * @param array $formData The submitted form field data (key-value pairs).
43 */
44 public function __construct(
45 int $optInId,
46 string $hash,
47 string $email,
48 string $confirmedIp,
49 int $formId,
50 array $formData = array()
51 ) {
52 parent::__construct();
53 $this->optInId = $optInId;
54 $this->hash = $hash;
55 $this->email = $email;
56 $this->confirmedIp = $confirmedIp;
57 $this->formId = $formId;
58 $this->formData = $formData;
59 }
60
61 /**
62 * {@inheritdoc}
63 */
64 public static function getWordPressHookName(): string {
65 return 'f12_cf7_doubleoptin_after_confirm';
66 }
67
68 /**
69 * Prevent the EventDispatcher from bridging this event to a WordPress hook.
70 *
71 * The legacy do_action( 'f12_cf7_doubleoptin_after_confirm', $hash, $optIn )
72 * is fired manually in AbstractFormIntegration and OptInFrontend with the
73 * original parameters for backward compatibility. Bridging here would cause
74 * the hook to fire twice.
75 *
76 * @return bool
77 */
78 public function shouldBridgeToWordPress(): bool {
79 return false;
80 }
81
82 public function getOptInId(): int {
83 return $this->optInId;
84 }
85
86 public function getHash(): string {
87 return $this->hash;
88 }
89
90 public function getEmail(): string {
91 return $this->email;
92 }
93
94 public function getConfirmedIp(): string {
95 return $this->confirmedIp;
96 }
97
98 public function getFormId(): int {
99 return $this->formId;
100 }
101
102 /**
103 * Get the submitted form field data.
104 *
105 * Returns the deserialized key-value pairs that the user submitted
106 * with the original form (e.g. ['your-name' => 'John', 'your-email' => 'john@example.com']).
107 *
108 * @return array
109 */
110 public function getFormData(): array {
111 return $this->formData;
112 }
113 }
114