OnBeforeUserDelete
bool handler function( int user_id );The event "OnBeforeUserDelete" fires before user is deleted. Usually, the purpose of this event handler is to allow or deny user deletion.
Parameters
Parameter | Description |
---|---|
user_id | Deleted user ID. |
Returned value
To cancel user deletion and and terminate the execution for the method CUser::Delete, throw an exception in the handler function via the methodSee Also
- "OnUserDelete" event
- [link= 6658369]CUser::Delete[/link]
- Events
Example:
<? // file /bitrix/php_interface/init.php // register the handler AddEventHandler("main", "OnBeforeUserDelete", Array("MyClass", "OnBeforeUserDeleteHandler"));
class MyClass { // create the event handler "OnBeforeUserDelete" public static function OnBeforeUserDeleteHandler($user_id) { // check if the records associated with the deleted user are available $strSql = "SEL ECT * FR OM my_table WHERE USER_ID=".intval($user_id); $rs = $DB->Query($strSql, false, "FILE: ".__FILE__."<br>LINE: ".__LINE__); // if the associated records are available if ($ar = $rs->Fetch()) { // deny user deletion global $APPLICATION; $APPLICATION->throwException("My table have the associated records."); return false; } } } ?>
© «Bitrix24», 2001-2024