| 1 |
<?php |
| 2 |
/** |
| 3 |
* OptIn Created 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 OptInCreatedEvent |
| 19 |
* |
| 20 |
* @api |
| 21 |
* |
| 22 |
* Dispatched when a new opt-in record is created after form submission. |
| 23 |
* Covered by the Addon API semver policy as of Core API 4.3.0. |
| 24 |
*/ |
| 25 |
class OptInCreatedEvent extends Event { |
| 26 |
|
| 27 |
private int $optInId; |
| 28 |
private int $formId; |
| 29 |
private string $formType; |
| 30 |
private string $email; |
| 31 |
private string $hash; |
| 32 |
private array $formData; |
| 33 |
|
| 34 |
/** |
| 35 |
* Constructor. |
| 36 |
* |
| 37 |
* @param int $optInId The opt-in record ID. |
| 38 |
* @param int $formId The form ID. |
| 39 |
* @param string $formType The form type (cf7, avada, etc.). |
| 40 |
* @param string $email The subscriber email. |
| 41 |
* @param string $hash The opt-in hash. |
| 42 |
* @param array $formData The submitted form data. |
| 43 |
*/ |
| 44 |
public function __construct( |
| 45 |
int $optInId, |
| 46 |
int $formId, |
| 47 |
string $formType, |
| 48 |
string $email, |
| 49 |
string $hash, |
| 50 |
array $formData = array() |
| 51 |
) { |
| 52 |
parent::__construct(); |
| 53 |
$this->optInId = $optInId; |
| 54 |
$this->formId = $formId; |
| 55 |
$this->formType = $formType; |
| 56 |
$this->email = $email; |
| 57 |
$this->hash = $hash; |
| 58 |
$this->formData = $formData; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* {@inheritdoc} |
| 63 |
*/ |
| 64 |
public static function getWordPressHookName(): string { |
| 65 |
return 'f12_cf7_doubleoptin_created'; |
| 66 |
} |
| 67 |
|
| 68 |
public function getOptInId(): int { |
| 69 |
return $this->optInId; |
| 70 |
} |
| 71 |
|
| 72 |
public function getFormId(): int { |
| 73 |
return $this->formId; |
| 74 |
} |
| 75 |
|
| 76 |
public function getFormType(): string { |
| 77 |
return $this->formType; |
| 78 |
} |
| 79 |
|
| 80 |
public function getEmail(): string { |
| 81 |
return $this->email; |
| 82 |
} |
| 83 |
|
| 84 |
public function getHash(): string { |
| 85 |
return $this->hash; |
| 86 |
} |
| 87 |
|
| 88 |
public function getFormData(): array { |
| 89 |
return $this->formData; |
| 90 |
} |
| 91 |
} |
| 92 |
|