Answer the question
In order to leave comments, you need to log in
How to send an email notification in Bitrix about adding an element through the website to the infoblock?
Hi all. Guys, I need your help. There was a task to create a form for adding reviews on Bitrix.
I created the "Reviews" infoblock and set it up. Reached the moment of creating a form for adding an element through the site. Everything seems to be clear, but I got into a stupor at a certain moment - it is necessary to send a notification to the corporate mail that a review has been written. I searched in Bitrix in the properties of the infoblock, and did not find anything. Guys, help pliz, tell me where to dig, how to do it?
Answer the question
In order to leave comments, you need to log in
Write your handler in the init.php file, the example below
is https://dev.1c-bitrix.ru/learning/course/index.php...
<?// регистрируем обработчик уведомления
AddEventHandler("iblock", "OnAfterIBlockElementAdd", Array("MessageAdd", "OnAfterIBlockElementAddHandler"));
class MessageAdd
{
// создаем обработчик события "OnAfterIBlockElementAddHandler"
function OnAfterIBlockElementAddHandler(&$arFields)
{
if($arFields["ID"]>0)
{
If($arFields['IBLOCK_ID'] == 4)
{
$arSend = array(
'TEXT' => $arFields['NAME'].' - товар '.$preview_picture.''.$detail_picture.''.$section.' , ID товара ='.$arFields["ID"]);
$arrSite = 's1';
CEvent::Send('ART_DTEX_IMPORT',$arrSite,$arSend);
}
}
}
}
There are no standard email notifications when an IB element is added.
Write an event handler for the OnAfterIBlockElementAdd event . In it, check the IBLOCK_ID for the one you need, and send the mail event via CEvent::Send
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question