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":

$eventName = $modx->event->name;
switch($eventName) {
    case 'OnBeforeEmptyTrash':
        // remote resource array

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

$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);

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.


  • modmore
  • Jens Wittmann – Gestaltung & Entwicklung
  • Digital Penguin
  • eydolan
  • deJaya
  • Following Sea
  • Nick Clark
  • Lefthandmedia
  • YJ
  • Sepia River Studios
  • Murray Wood
  • Dannevang Digital
  • Richard


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

Learn more