Trigger "mailpoet_segment_subscribed" hook when globally subscribed via admin
[MAILPOET-5992]
This commit is contained in:
@@ -165,6 +165,20 @@ class SubscriberSaveController {
|
||||
$this->welcomeScheduler->scheduleSubscriberWelcomeNotification($subscriber->getId(), $newSegments);
|
||||
}
|
||||
|
||||
// when global status changes to subscribed, fire subscribed hook for all subscribed segments
|
||||
if (
|
||||
$subscriber->getStatus() === SubscriberEntity::STATUS_SUBSCRIBED
|
||||
&& $oldStatus !== null // don't trigger for new subscribers (handled in subscriber segments repository)
|
||||
&& $oldStatus !== SubscriberEntity::STATUS_SUBSCRIBED
|
||||
) {
|
||||
$segments = $subscriber->getSubscriberSegments();
|
||||
foreach ($segments as $subscriberSegment) {
|
||||
if ($subscriberSegment->getStatus() === SubscriberEntity::STATUS_SUBSCRIBED) {
|
||||
$this->wp->doAction('mailpoet_segment_subscribed', $subscriberSegment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $subscriber;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user