Documentation

OnBeforeEventAdd

handler function(
 string &$event,
 string &$lid,
 array &$arFields,
 string &$message_id,
 string &$files,
 string languageId = ''
)
The OnBeforeEventAdd event fires when mail event is added to the table b_event. Generally, the objective of this event handler is to modify or add a value, passed to mail template marco.  

Parameters

ParameterDescription Available from version
$event Mail event type ID, for example APPLICATION_FORM_FILLING
$lid Site ID, from which the method CEvent::Send() was called
$arFields Array of parameters, passed to event handler.
Example of array:
Array
        (
            [RS_FORM_ID] => 1
            [RS_FORM_NAME] => Site visitor form
            [RS_FORM_VARNAME] => FORM
            [RS_FORM_SID] => FROM
            [RS_RESULT_ID] => 11
            [RS_DATE_CREATE] => 24.07.2011 16:59:55
            [RS_USER_ID] => 1
            [RS_USER_EMAIL] => my@email.com
            [RS_USER_NAME] =>  
            [RS_USER_AUTH] =>  
            [RS_STAT_GUEST_ID] => 1
            [RS_STAT_SESSION_ID] => 1
            [VS_NAME] => sfdsf
            [VS_NAME_RAW] => sfdsf
            [VS_BIRTHDAY] => 21.07.2011
            [VS_BIRTHDAY_RAW] => 21.07.2011
            [VS_ADDRESS] => sdfdsf
            [VS_ADDRESS_RAW] => sdfdsf
            [VS_MARRIED] => Yes [4]
            [VS_MARRIED_RAW] => Yes
            [VS_INTEREST] => physics (2) [7]
                             programming (5) [10]
            [VS_INTEREST_RAW] => physics, programming
            [VS_AGE] => 30-39 (30) [13]
            [VS_AGE_RAW] => 30-39
            [VS_EDUCATION] => higher (3) [19]
            [VS_EDUCATION_RAW] => higher
            [VS_INCOME] =>  
            [VS_INCOME_RAW] =>  
            [VS_PHOTO] =>  
            [VS_PHOTO_RAW] =>  
        )
$message_idMail template ID (if specified). If the variable is defined in the handler, a single type will be sent only with this ID among several mail templates, but not all of them.
$filesFIle
$languageId (Default - current language). Responsible for sending notifications in a specified language ("Language" parameter for mail templates). All templates without the specified language are sent, as well as the templates which language corresponds to $languageId.

Filter by the template language is not available if the $messageId variable is passed.

Example of handler function:

<?
class MyClass
{
    public static function onBeforeEventAdd(&$event, &$lid, &$arFields, &$messageId, &$files, &$languageId)
    {
         // code
    }
}
?>
16.5.8

Returned value

Note. Starting from kernel version 11.0.16 when returns false, adding a new mail event is cancelled.

See Also

Example of handler function

<?
//Handler in the file /bitrix/php_interface/init.php
AddEventHandler("main", "OnBeforeEventAdd", array("MyClass", "OnBeforeEventAddHandler"));
class MyClass
{
	public static function OnBeforeEventAddHandler(&$event, &$lid, &$arFields)
	{
		$arFields["NEW_FIELD"] = "New marco for mail template";
		$arFields["VS_BIRTHDAY"] = "Existing macro update";
		$lid = 's2'; //Modify attachment to site  
	}
}
?>



© «Bitrix24», 2001-2024