bool event_handler( int user_id );
The OnBeforeUserDelete event fires before the user is deleted. A common use of this module is to allow or disallow the user deletion.
Parameter | Description |
---|---|
user_id | The ID of the user which is to be deleted. |
To cancel the site deletion and terminate the CUser::Delete method, raise an exception from within the handler using the method
<? // file /bitrix/php_interface/init.php // register handler AddEventHandler("main", "OnBeforeUserDelete", Array("MyClass", "OnBeforeUserDeleteHandler")); class MyClass { // create handler "OnBeforeUserDelete" function OnBeforeUserDeleteHandler($user_id) { // check if any records exist bound to the deleted language $strSql = "SELECT * FROM my_table WHERE USER_ID=".intval($user_id); $rs = $DB->Query($strSql, false, "FILE: ".__FILE__."<br>LINE: ".__LINE__); // if found... if ($ar = $rs->Fetch()) { // cancel deletion. global $APPLICATION; $APPLICATION->throwException("My table has bound records."); return false; } } } ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |