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 NameFires When…
after_invoice_addedA new invoice is created
after_invoice_updatedAn invoice is updated
after_payment_recordedA payment is recorded on an invoice
after_ticket_createdA new support ticket is opened
after_ticket_status_changedTicket status is changed
after_lead_addedA new lead is created
after_lead_convertedA lead is converted to a customer
after_customer_addedA new customer is saved
after_project_createdA new project is created
after_task_status_changedTask status is changed
app_initEvery 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.