BeforePostingSendMail
Description and parameters
handler function( array arFields );The event "BeforePostingSendMail" is called before sending a message from method CPosting::SendMessage.
Parameters
Parameter | Description |
---|---|
arFields | Array containing the following:
|
This handler must return an array with similar contents. This array will be passed as an argument to the next handler. Handler result integrity check is not performed in the module.
If the handler doesn't return an array, no email is sent. However, in case of false return, the email is deemed unsent, otherwise the sending will be marked as successful.
See Also
Example of handler function
<?
// file /bitrix/php_interface/init.php
// register the handler
AddEventHandler("subscribe", "BeforePostingSendMail", Array("MyClass", "BeforePostingSendMailHandler"));
class MyClass { // create event handler "BeforePostingSendMail" public static function BeforePostingSendMailHandler($arFields) { $USER_NAME = "Subscriber"; //Attempt to find a subscriber. $rs = CSubscription::GetByEmail($arFields["EMAIL"]); if($ar = $rs->Fetch()) { if(intval($ar["USER_ID"]) > 0) { $rsUser = CUser::GetByID($ar["USER_ID"]); if($arUser = $rsUser->Fetch()) { $USER_NAME = $arUser["NAME"]." ".$arUser["LAST_NAME"]; } } } $arFields["BODY"] = str_replace("#NAME#", $USER_NAME, $arFields["BODY"]);
return $arFields;
}
}
?>
© «Bitrix24», 2001-2024