Answer the question
In order to leave comments, you need to log in
How to track user registration confirmation?
Hello, friends! Happy New Year to you!
I ask for your help. The situation is as follows: I have the simplest event handler: when a user registers, CIBlockElement::Add() is executed - it adds an element to the IB with a binding to the registered user and several more properties. I’ll make a reservation right away that this action needs to be done only once - during registration - this is a kind of "accrual bonus for registration."
This handler copes with its task, but on the condition that confirmation of registration from the user is not requested. If I turn on the registration confirmation, after the user submits the form, he sees a white sheet. This is because USER_ID is not assigned to him immediately, but only after clicking on the link from the letter.
Question:on which event should I hang this handler so that it is executed when the user confirms registration? From googling, I figured out that maybe CUser::Update() should be used. Is it so?
Existing handler code:
AddEventHandler("main", "OnAfterUserRegister", "AddBonusOnRegister");
function AddBonusOnRegister(&$arFields){
include $_SERVER['DOCUMENT_ROOT'].'/cbk/vars.php';
CModule::IncludeModule("iblock");
if($arFields["USER_ID"] > 0){
// Добавляем бонус как покупку
$prop[164] = $arFields["USER_ID"]; // Привязка к пользователю
/* ... Еще несколько свойств ... */
$arLoadProductArray = Array(
"IBLOCK_SECTION_ID" => false,
"IBLOCK_ID" => $ORDERS_IBLOCK_ID,
"PROPERTY_VALUES"=> $prop,
"NAME" => "Бонус за регистрацию (".$arFields['LOGIN'].")",
"ACTIVE" => "Y"
);
$bonus = new CIBlockElement;
if(!$bonus->Add($arLoadProductArray)){
echo "Ошибка при начислении бонуса: ".$bonus->LAST_ERROR."<br/>";
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question