DMSI Webhooks exposes the following WordPress filters for programmatic customization.
dmsi_register_webhook_event #
Register additional custom event types.
Parameters: array $events — existing event definitions
Return: Modified events array
add_filter('dmsi_register_webhook_event', function(array $events): array {
$events[] = [
'name' => 'order.shipped',
'category' => 'custom',
'description' => 'Fires when an order is shipped',
'sample_payload' => ['order_id' => 123],
];
return $events;
});
dmsi_webhook_endpoints_{event_name} #
Override the list of endpoints that receive deliveries for a specific event. Replace {event_name} with the event name using underscores instead of dots: dmsi_webhook_endpoints_license_created.
Parameters: ($endpoints, $event_name, $context)
add_filter('dmsi_webhook_endpoints_license_created', function($endpoints, $event, $context) {
// Only deliver to endpoints with auto_subscribe enabled
return array_filter($endpoints, fn($ep) => $ep->auto_subscribe);
}, 10, 3);
dmsi_webhook_should_send #
Skip a specific delivery for a given endpoint/event combination.
Parameters: ($should_send, $endpoint, $event_name, $data, $context)
Return: bool
add_filter('dmsi_webhook_should_send', function($should_send, $endpoint, $event, $data, $context) {
// Skip deliveries to debug-mode endpoints outside admin context
if ($endpoint->debug_mode && !is_admin()) {
return false;
}
return $should_send;
}, 10, 5);
dmsi_webhook_payload_{event_name} #
Modify the payload for a specific event before delivery. Replace {event_name} with underscores instead of dots.
Parameters: ($payload, $webhook_id, $context)
Return: Modified payload array. Note: event, webhook_id, and timestamp are restored if removed.
add_filter('dmsi_webhook_payload_license_created', function($payload, $webhook_id, $context) {
// Add a custom field to the data
$payload['data']['source_environment'] = wp_get_environment_type();
return $payload;
}, 10, 3);
dmsi_webhook_transform_payload #
Final payload transformation hook, applied after all per-endpoint customization rules.
Parameters: ($payload, $endpoint_id, $event_name)
Return: Modified payload array
add_filter('dmsi_webhook_transform_payload', function($payload, $endpoint_id, $event_name) {
// Strip internal fields before delivery to a specific endpoint
if ($endpoint_id === 12) {
unset($payload['data']['internal_user_id']);
}
return $payload;
}, 10, 3);
dmsi_webhooks_license_valid #
Override the license validity check that gates delivery scheduling. Use with caution.
Parameters: (bool $valid)
Return: bool
add_filter('dmsi_webhooks_license_valid', function(bool $valid): bool {
// Always valid in local/staging environments
if (wp_get_environment_type() !== 'production') {
return true;
}
return $valid;
});
Related Topics #
- Available WordPress Actions
- Registering Custom Events
- Payload Customization
