Jump to main content Jump to doc navigation

Event: OnBeforeEmptyTrash

Fires before the trash is emptied for the site.

  • Service: 1 - Parser Service Events
  • Group: Documents

Event Parameters

Name Description
ids An array of Resource IDs that will be permanently deleted.

Examples of

Such a plugin will display the id of remote resources in the "Error log":

<?php
$eventName = $modx->event->name;
switch($eventName) {
    case 'OnBeforeEmptyTrash':
        // remote resource array
        print_r($ids);
        break;
}

Such a plugin will display a message stating that there is an important document in the shopping cart and it cannot be deleted:

<?php
$eventName = $modx->event->name;
switch($eventName) {
    case 'OnBeforeEmptyTrash':
        // if there is a document with id = 26, then do not delete
        if (in_array("26", $ids)){
            $response = array(
            	'success' => false,
            	'message' => 'HEY! There is a document that cannot be deleted!',
            	'data' => array(),
            );
            echo $modx->toJSON($response);
            exit;
        }
        break;
}

See Also

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Digital Penguin
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Following Sea
  • Anton Tarasov
  • eydolan
  • Raffy
  • Lefthandmedia
  • Murray Wood
  • Snow Creative
  • Nick Clark
  • Helen
  • JT Skaggs
  • krisznet
  • YJ
  • Yanni
  • Richard

Budget

$366 per month—let's make that $500!

Learn more