Action hooks let you run custom PHP code at specific points in AlgoSphere's execution — without modifying core files. All customisations survive updates.
How Hooks Work
AlgoSphere fires named action hooks throughout its codebase. By registering a listener for a hook, your custom code runs automatically when that event occurs.
hooks()->add_action('hook_name', 'my_function');
function my_function($data) {
// your custom code here
}
Common Action Hooks
| Hook Name | Fires When… |
|---|---|
after_invoice_added | A new invoice is created |
after_invoice_updated | An invoice is updated |
after_payment_recorded | A payment is recorded on an invoice |
after_ticket_created | A new support ticket is opened |
after_ticket_status_changed | Ticket status is changed |
after_lead_added | A new lead is created |
after_lead_converted | A lead is converted to a customer |
after_customer_added | A new customer is saved |
after_project_created | A new project is created |
after_task_status_changed | Task status is changed |
app_init | Every page load (use sparingly) |
Filter Hooks
Filter hooks allow you to modify and return data rather than just execute code:
hooks()->add_filter('filter_name', 'my_filter_function');
function my_filter_function($data) {
// modify $data
return $data;
}
Best Practice
Always implement hooks inside a module rather than directly in core files. This ensures your customisations survive AlgoSphere updates.