Home / Addons and Modules / Creating Addons

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

  1. Create modules/addons/youraddon/.
  2. Add module.json with name, display_name, description, version, author.
  3. Add hooks.php. Use HookManager::addAction() or HookManager::addFilter() with hook names from the Hooks Reference.
  4. Go to Admin → Addons, find your addon, click Enable.
  5. 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?

Tags: Developer