Answer the question
In order to leave comments, you need to log in
Why doesn't the handler fire when the event is caught?
There is an event handler when creating an infoblock in init.php
<?php
// регистрация обработчика в /bitrix/php_interface/init.php
AddEventHandler(12, "OnAfterIBlockElementAdd", "admissionToReferal");
$result = admissionToReferal($arFields);
if($result){echo 'Функция сработала';}
else echo 'Функция не сработала';
function admissionToReferal($arFieldsParam)
{
if($arFieldsParam["ID"]>0){
//событие при добавлении блока Платёж
$payId = $arFieldsParam["ID"];
$arSelect = Array("ID", "SEND");
$arFilter = Array("IBLOCK_ID"=>12, "ID"=>$payId);
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
while($ob = $res->GetNextElement()){
$arFields = $ob->GetFields();
$arProps = $ob->GetProperties();
print_r($arFields);
print_r($arProps);
}
}
}
?>
Answer the question
In order to leave comments, you need to log in
your admissionToReferal function does not return any result (i.e. returns NULL), because of this, the line "The function did not work" is displayed.
However, this does not mean that the function failed.
Call die() in the body of the function and see if it worked
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question