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
$varsarray with event data such assubscriber_id,list_id,email, orcampaign_id; log$varsduring development to see exactly what a given hook provides.Fire hooks yourself with
listen_hook()(synchronous) orrun_hook_in_background()(queued via Laravel's queue — ideal for notifications, external API syncs, and heavy processing).Output hooks like
HeadTopandFooterreturn HTML strings; retrieve their content withhook_get_output(),hook_get(), orhook_get_all(), and check registration withhook_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.
