M
M
Misha Vasilyev2013-11-25 16:11:18
1C-Bitrix
Misha Vasilyev, 2013-11-25 16:11:18

How to track user subscription confirmation in 1C-Bitrix?

Hello!
There was an urgent need to track the moment when the user confirmed his desire to receive the newsletter (after that, it is planned to give him points to pay for the purchase). I habitually went to http://dev.1c-bitrix.ru/ but for subscriptions I saw only 1 event: BeforePostingSendMail. Of course, every time I send a letter, I can see if points have already been accrued to this user (for transactions, at least, if possible, I haven’t looked yet) and if not, then accrue. But isn't there a better way? If anyone has come across, please let me know!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Misha Vasiliev, 2013-11-26
@vasilyev

Did it in a stupid way, but it's better (for me) than DB triggers.
1. We fork the subscribe.edit component.
2. Inside component.php we are looking for a block:

//confirmation code from letter or confirmation form
if($_REQUEST["CONFIRM_CODE"] <> "" && $ID > 0 && empty($_REQUEST["action"]))
{
  if($arSubscription["CONFIRMED"] <> "Y" && count($arWarning)==0)
  {
    //subscribtion confirmation
    if($obSubscription->Update($ID, array("CONFIRM_CODE"=>$_REQUEST["CONFIRM_CODE"])))
      $arSubscription["CONFIRMED"] = "Y";
    if($obSubscription->LAST_ERROR<>"")
      $arWarning[] = $obSubscription->LAST_ERROR;
    $iMsg = $obSubscription->LAST_MESSAGE;
        //тут делаем то, что нам нужно.
  }
}

Naturally, this will not work if the subscription was not confirmed through the component (for example, in the admin panel), but personally I realized that I didn’t need it.

M
MHumster, 2013-11-26
@MHumster

Alas, with Bitrix, everything is not always obvious. I personally implemented the subscription / unsubscription mechanism manually through the API and resp. took control of all events.
Sometimes it is convenient to move the functionality to the database - put a trigger on the desired table and catch events there.
In general, the entire Bitrix is ​​essentially read-write from the database, you can crawl anywhere if you don’t drive on components and a standard API.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question