Bitrix Site Manager

OnBeforeIBlockElementDelete

bool
event_handler(
 int ID
);
Fired before the information block element is deleted by CIBlockElement::Delete. A common task of this handler is to cancel or approve the deletion.

Parameters

ParameterDescription
ID The ID of the element to be deleted.

Return Values

To cancel the element deletion and terminate CIBlockElement::Delete, throw an exception by calling $APPLICATION->ThrowException() and return false.

See Also

  • CIBlockElement::Delete
  • Handling events

    Example

    
    <?
    // file /bitrix/php_interface/init.php
    // register handler
    AddEventHandler("iblock", 
                    "OnBeforeIBlockElementDelete", 
                    Array("MyClass", "OnBeforeIBlockElementDeleteHandler"));
    
    class MyClass
    {
        // create handler "OnBeforeIBlockElementDelete"
        function OnBeforeIBlockElementDeleteHandler($ID)
        {
            if($ID==1)
            {
                global $APPLICATION;
                $APPLICATION->throwException("the element ID=1 cannot be deleted.");
                return false;
            }
        }
    }
    ?>