Events system
WP-PFManagement's event system is the backbone for automation. Every record creation, update, and deletion fires an event that workflows and external systems can react to.
Built-in system events
| Event slug | When it fires | Payload |
|---|---|---|
pfm.record.created | After a record is inserted | Full record data |
pfm.record.updated | After a record is updated | Previous values + changes map |
pfm.record.deleted | After a record is deleted | Record sys_id and entity |
pfm.entity.created | After an entity is created | Entity definition |
pfm.entity.updated | After an entity definition changes | Old + new entity definitions |
pfm.entity.deleted | After an entity is removed | Entity slug |
pfm.journal.created | After a journal entry is created | Journal entry data |
Event payload (record.updated)
{
"entity": "ticket",
"record": { "sys_id": "...", "title": "Updated title", "status": "closed" },
"previous": { "title": "Old title", "status": "open" },
"changes": { "title": "Updated title", "status": "closed" }
}
The changes map only includes fields whose values actually changed. The previous snapshot includes all fields before the update.
Custom events
Register new events via REST: POST /pfm/v1/events/catalog
Fire events via REST: POST /pfm/v1/events/{slug}/fire
Custom events require the pfm_fire_events capability.
Workflow integration
Events automatically translate to WP-PFWorkflow triggers:
pfm.record.created→ workflow trigger "Record created" for the entitypfm.record.updated→ workflow trigger "Record updated" for the entitypfm.record.deleted→ workflow trigger "Record deleted" for the entity
The trigger payload contains the full record data + event metadata.
Event log
GET /pfm/v1/events/log — queryable by slug, actor, record, time range. Stored in wp_pfm_event_log. Pruned daily to keep max 50,000 rows (configurable via pfm_event_log_max_rows option).