Add mailpoet_subscription_before_subscribe hook

In order for 3rd parties to hook into the subscription process, e.g. to
validate the data themselves, the action hook
mailpoet_subscription_before_subscribe has been added. [MAILPOET-3632]
This commit is contained in:
David Remer
2022-01-27 15:36:14 +02:00
committed by Veljko V
parent 93e294fb38
commit b1f51714ca

View File

@@ -119,6 +119,17 @@ class SubscriberSubscribeController {
return $meta;
}
/**
* Fires before a subscription gets created.
* To interrupt the subscription process, you can throw an MailPoet\Exception.
* The error message will then be displayed to the user.
*
* @param array $data The subscription data.
* @param array $segmentIds The segment IDs the user gets subscribed to.
* @param FormEntity $form The form the user used to subscribe.
*/
$this->wp->doAction('mailpoet_subscription_before_subscribe', $data, $segmentIds, $form);
$subscriber = $this->subscriberActions->subscribe($data, $segmentIds);
if (!empty($captchaSettings['type']) && $captchaSettings['type'] === Captcha::TYPE_BUILTIN) {