D
D
Dickie Dick2020-11-11 20:40:54
1C-Bitrix
Dickie Dick, 2020-11-11 20:40:54

Is there an event for adding a new subscriber in the bitrix:sender.subscribe component?

Good day!

The site contains the bitrix:sender.subscribe component - the subscription form. The user enters his e-mail into it, presses "Subscribe" - and as a result I can see his e-mail in the Address List (Administration->Marketing->Email-marketing->Address List).

Question - is there any event in Bitrix that can be used to catch the moment a new subscription is added to this list? I can’t find any clues in the Bitrix documentation. Unless some 3 events are mentioned on this page:
https://dev.1c-bitrix.ru/api_d7/bitrix/sender/subs...
But somehow I couldn't use them.

I also tried to apply a code snippet found on the Bitrix forum:

$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandlerCompatible('crm', '\\Bitrix\\Sender\\Contact::onBeforeAdd', ['myEvents','onBeforeAddHandler']);


But that code didn't work either. Can someone clarify the situation, maybe I'm looking for something that doesn't exist?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2020-11-12
@DickieDick

The bitrix:sender.subscribe component adds a mailing list subscription using the \Bitrix\Sender\Subscription::add method.
Inside the method, first, the presence of the transmitted email in the contact database is checked, and if EMAIL is not there, then it is added. And after adding a subscription to the specified mailing lists.
Adding a contact occurs in the ORM table Bitrix\Sender\ContactTable
Subscribing to the Bitrix\Sender\MailingTable mailing list You can
subscribe to an event like this:

$eventManager = Main\EventManager::getInstance();
$eventManager->addEventHandler(
    "sender",
    "\Bitrix\Sender\ContactTable::onAfterAdd",
    ['myEvents','onBeforeAddHandler']
);

By subscribing to the add event in the ContactTable, you will be able to handle the options for adding NEW contacts. But if the old user uses the subscription, the handler will not work.
When subscribing to add MailingTable, you will catch ALL subscriptions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question