Resources
Resources
Events
Craft has all kinds of events you can use to customize how things work. See Using Events in a Custom Module for an example of how to wire up event code using a module.
Event Code Generator
Select an event for more detail and a code snippet.
Common Event Flows
Saving Entries
While every element in Craft CMS has a common set of events your custom code can subscribe to, the entry-saving workflow is one of the most common and complex.
See Handling Entry Saves for more on entry-specific concepts.
Generally, entries progress through the following order of operations:
- Pre-flight checks that trigger
EVENT_BEFORE_SAVE
. - Validation that triggers
EVENT_BEFORE_VALIDATE
andEVENT_AFTER_VALIDATE
. - Saving for the initial site that triggers
EVENT_AFTER_SAVE
. - Propagating non-translatable changes to the entry’s other sites, which repeats steps 1-3 for each site before triggering
EVENT_AFTER_PROPAGATE
.