Creating Addons
module.json, hooks.php, admin pages
What it is
Addons extend WHMDC without modifying core files. Each addon lives in modules/addons/youraddon/ and can register hooks, add admin pages, and run code at specific points in the system.
How it works
WHMDC discovers addons from modules/addons/. When you enable an addon in Admin → Addons, its hooks.php is loaded automatically. Hooks registered there will run whenever the corresponding events occur.
Directory structure
modules/addons/myaddon/
├── module.json # Name, version, description
├── hooks.php # HookManager::addAction, addFilter calls
└── admin/ # Optional admin UI
└── settings.php
module.json
{
"name": "myaddon",
"display_name": "My Addon",
"description": "Does something useful",
"version": "1.0.0",
"author": "Your Name"
}
hooks.php
<?php
// Run when an invoice is created
HookManager::addAction('slack_invoice_created', function($data) {
$invoiceId = $data['invoice_id'] ?? 0;
// Your logic: send notification, sync to CRM, etc.
}, 10);
Step-by-step setup
- Create
modules/addons/youraddon/. - Add
module.jsonwith name, display_name, description, version, author. - Add
hooks.php. UseHookManager::addAction()orHookManager::addFilter()with hook names from the Hooks Reference. - Go to Admin → Addons, find your addon, click Enable.
- Your hooks will now run. No cache clear needed.
Finding the right hook
Use the Hooks Reference to see every available hook, when it fires, and what parameters it passes. Choose the hook that matches the event you want to react to.
Was this helpful?