Plugin Hooks Notifications
This guide shows how to emit hooks from your plugin and let Notificator Companion turn those events into push/MQTT notifications.
How it works
Section titled “How it works”- Your plugin emits a WordPress action/filter hook.
- Notificator Companion listens to configured hook names.
- On trigger, it builds payload and sends notification.
Emit a custom action hook
Section titled “Emit a custom action hook”In your plugin code:
<?php// Example event: after custom order is created.do_action('my_plugin_order_created', $order_id, $user_id, $amount);Then in Notificator Companion UI:
- Add scenario with
hook_name:my_plugin_order_created - Set scenario name/notes
- Enable send push / send mqtt as needed
Emit with wrapper functions
Section titled “Emit with wrapper functions”The scanner supports prefixed wrappers too (for example gf_do_action).
<?phpgf_do_action('my_plugin_sync_completed', $job_id, $duration_ms);Filter-based events
Section titled “Filter-based events”Filter hooks can be used as trigger sources as well.
<?php$value = apply_filters('my_plugin_before_export', $value, $context);Conditions and payload tips
Section titled “Conditions and payload tips”When defining scenario conditions:
- Use stable argument order in your hook calls.
- Keep argument types predictable (number/string).
- Use descriptive scenario names for easier triage.
Example condition target:
- field:
user_id - operator:
>= - value:
1
Recommended production safeguards
Section titled “Recommended production safeguards”- Keep hook names unique and namespaced (
my_plugin_*). - Use Notificator throttle settings to avoid noisy bursts.
- Test each scenario with controlled sample events first.
Troubleshooting
Section titled “Troubleshooting”No notifications on hook trigger:
- Confirm scenario is enabled.
- Confirm exact hook name match.
- Re-run plugin hook scan in Notificator admin.
- Check plugin log entries and Netlify/API logs.
- Verify API key and endpoint settings.