Custom hooks let you run your own PHP code when events happen in Mumara Campaigns. You create a PHP file in the /includes/hooks/ directory and register callbacks with add_hook($hook, $priority, $callback) — files in that directory are loaded automatically, so no other wiring is needed.
Key concepts:
Priority controls execution order when multiple callbacks share a hook — lower numbers run first (use 1–3 for critical work, 5–10 for standard operations, 10+ for cleanup or logging).
Most hooks pass a $vars array with event data such as subscriber_id, list_id, email, or campaign_id; log $vars during development to see exactly what a given hook provides.
Fire hooks yourself with listen_hook() (synchronous) or run_hook_in_background() (queued via Laravel's queue — ideal for notifications, external API syncs, and heavy processing).
Output hooks like HeadTop and Footer return HTML strings; retrieve their content with hook_get_output(), hook_get(), or hook_get_all(), and check registration with hook_exist().
Always wrap risky code in try-catch and log instead of re-throwing, so one failing hook doesn't stop the others; enabling hook error logging in Application Settings writes errors to storage/logs/laravel.log. Prefer named functions with a unique company prefix for easier debugging, and use php artisan queue:work --once to test background hooks.