AddEventHandler( string from_module_id, string event_id, mixed callback, int sort = 100, mixed full_path = false );
The function AddEventHandler registers an event handler (callback) of an event event_id with the module from_module_id. If a full path to the file containing the handler is specified (full_path), the file will be included before calling the handler.
Parameter | Description |
---|---|
from_module_id | The ID of the module whose event is to be processed. |
event_id | The event ID. |
callback | The user defined event handler function. If a class method is to be passed in this parameter, pass an array in the format Array(class(object), method name) here. |
sort | Order in which the registered handler is to be called (more than one handler can be registered for an event). Optional, 100 by default. |
full_path | Full path to the file which is to be included upon event before calling the handler callback. |
<? // file /bitrix/php_interface/init.php AddEventHandler("main", "OnBeforeUserLogin", Array("MyClass", "BeforeLogin")); class MyClass { function BeforeLogin(&$arFields) { if(strtolower($arFields["LOGIN"])=="guest") { global $APPLICATION; $APPLICATION->throwException("User with login "Guest" cannot be authorised."); return false; } } } ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |