Documentation

OnBeforeIBlockElementDelete

bool
event_handler(
 int ID
);
The event OnBeforeIBlockElementDelete is 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 ThrowException() and returns false.

See Also

  • CIBlockElement::Delete

    Example

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