Skip to content

When an entry is deleted

Sends a notification when an Entry has been deleted. Multi-site entries fire this trigger once (when the canonical record is deleted), regardless of how many sites the entry was propagated to.

This trigger fires for both soft deletes (moved to the trash) and hard deletes. Restoring a deleted entry fires the separate "When an entry is restored" event.

Field Conditions

Field conditions restrict the notification based on the element's content, using Craft's native conditions framework. Build a rule set against the element's attributes and field values, and the notification will be sent only when every rule matches.

Must match all conditions

The condition builder evaluates every rule with AND semantics, so each rule must pass for the notification to be sent.

Twig variables

The object variable (and its entry alias) is the deleted Entry.

twig
"{{ entry.title }}" was just deleted.

Examples

Alert administrators of a deletion

twig
{{ entry.title }} was deleted by {{ currentUser.fullName }}.

- Section: {{ entry.section.name }}
- Type: {{ entry.type.name }}
- Slug: {{ entry.slug }}

Skip deletions in a specific section

twig
{% if entry.section.handle == 'scratch' %}
    {% skipMessage "Scratch entries are not announced." %}
{% endif %}

Deleted: {{ entry.title }}

Notify the entry's author

twig
Hi {{ entry.author.firstName }},

Heads up: "{{ entry.title }}" was deleted by {{ currentUser.fullName }}.

If you need it back, ask an admin to restore it from the trash.