Bitrix Site Manager

OnUserDelete

event_handler(
 int user_id
)

The OnUserDelete event fires when a user is deleted. A common task of this handler is to clean the database of records related to the deleted user.

Parameters

ParameterDescription
user_id The ID of the user which is to be deleted.

See Also

Example



<?
// file /bitrix/modules/my_module_id/include.php
class MyClass
{
    // create handler "OnUserDelete"
    function OnUserDeleteHandler($user_id)
    {
        // delete related records
        $strSql = "DELETE FROM my_table WHERE USER_ID=".
                  intval($user_id);
        $rs = $DB->Query($strSql, false, 
                         "FILE: ".__FILE__."<br>LINE: ".__LINE__);
    }
}
?>

Example of handler registration


<?
// register handler "OnUserDelete"
RegisterModuleDependences("main", "OnUserDelete", 
                          "my_module_id", "MyClass", 
                          "OnUserDeleteHandler");
?>