Hooks are the main extensibility mechanism in Mumara Campaigns: callback functions that run when specific events occur, letting you add custom behavior without modifying core files. Use them to integrate external systems (CRMs, analytics), customize the interface, automate workflows, or build full addons.
The system follows a simple publish-subscribe pattern — you register a callback with add_hook('HookName', $priority, $callback), and when the event fires, all registered callbacks execute in priority order (lower numbers first). There are two categories:
Module hooks fire on application events — contact add/edit/delete, list management, campaign start/pause/complete, domain and SMTP changes, user actions. Ideal for CRM sync, notifications, audit trails, and business logic.
Output hooks inject content into page locations — HeadTop/HeadEnd for styles and meta tags, BodyTop/BodyEnd for scripts, Footer, PrimaryMenu for navigation, AlertBar for banners.
Hook files are plain PHP files placed in the /includes/hooks/ directory (an example.php template is included as a reference). Hooks can run synchronously with listen_hook() or be queued for background execution with run_hook_in_background() — prefer background mode for slow operations so user requests aren't delayed. Best practices: prefix function names to avoid collisions, wrap code in try-catch, keep hooks lightweight, and test thoroughly, since hooks can affect core functionality.