A WHMCS addon module is a folder under modules/addons holding one PHP file named after the folder. Only the config function is required; activate, deactivate, upgrade, output, sidebar and clientarea are optional. Create the folder, write config, activate the module at Configuration > System Settings > Addon Modules, tick the admin roles that may open it, then add your pages.
An addon module is the WHMCS module type for a feature that belongs to the whole install rather than to one product: a staff page, a client page, a set of hooks, or all three. It lives at /modules/addons/your_module_name/your_module_name.php, and WHMCS calls its functions by name. Once activated it appears under the Addons menu, and only the administrator roles you tick can open it.
Everything below is checked against the WHMCS developer documentation, the 9.1 documentation and WHMCS's own sample addon module, read on 2 December 2026. One limit comes first: the Custom Modules page says custom modules are for self-hosted installs, because WHMCS Cloud does not currently support them.

Which jobs belong in an addon module?
Jobs that are not tied to one product and not tied to a payment or a domain. The addon modules overview puts it plainly: an addon module can be just an admin page, just hooks, or both. A reporting screen for staff, a bulk tool, an integration with an internal system: those are addon jobs.
Three jobs are not. Creating and suspending a service on another system is a provisioning module, covered in my custom provisioning module guide. Taking payments is a gateway module, and selling domains is a registrar module. Reacting to an event with no settings and no page needs only a hook file, which my hooks guide covers. To weigh the four types against each other, read WHMCS module types.

How do you name the folder and the files?
The folder name is the module name, and the main file repeats it with a .php extension. The addon getting started page gives the rule: unique, all lowercase, letters and numbers only, starting with a letter, with underscore the one accepted special character. Its examples are mymodulename, my_module_name and my_module.

Every function is prefixed with that name and an underscore, so a module called billingsync defines billingsync_config(). Pick the name once: renaming later means renaming the folder, the file and every function. The name also becomes part of the client URL, index.php?m=your_module_name, so it is public.
WHMCS publishes a sample addon module on GitHub under the MIT license and recommends it as the starting point. Its README gives the recommended layout:
addonmodule/
|- lang/
|- lib/
|- templates/
| addonmodule.php
| hooks.php
| logo.png
Only addonmodule.php is required. The rest is structure: language strings in lang/, classes in lib/, Smarty templates in templates/, hooks in hooks.php.
What goes in the config function?
The module's identity and its settings form. The configuration page shows a config function returning an array with name, description, version, author and a fields array. The name is what staff see, and the version number is what triggers the upgrade function later.
Six field types are supported. Each becomes a row on the configure screen, and the saved value is passed back to every other function.
| Type | What staff see | Extra parameters |
|---|---|---|
text | Single line input | Size, Default, Description |
password | Masked input | Size, Default, Description |
yesno | One checkbox | Description |
dropdown | Select menu | Options, required; Default |
radio | Radio buttons | Options, comma separated; Default |
textarea | Multi-line box | Rows, Cols, Default |
The documentation shows Options as a comma separated string, but the sample module also passes an associative array for a dropdown, so the stored value and the label can differ.
<?php
use WHMCS\Database\Capsule;
if (!defined('WHMCS')) {
die('This file cannot be accessed directly');
}
function billingsync_config()
{
return [
'name' => 'Billing Sync',
'description' => 'Sends invoices to the finance system.',
'author' => 'Your name',
'language' => 'english',
'version' => '1.0',
'fields' => [
'apiKey' => ['FriendlyName' => 'API Key', 'Type' => 'password', 'Size' => '40'],
'mode' => [
'FriendlyName' => 'Mode',
'Type' => 'dropdown',
'Options' => ['live' => 'Live', 'test' => 'Test'],
'Default' => 'test',
],
],
];
}
Set Default on anything that causes damage when it is wrong. A mode field defaulting to Test has saved me awkward calls.
What do activate, deactivate and upgrade do?
They run your database work at the three moments WHMCS tells you about: activation, deactivation, and the first page load after the version number changes. The installation and uninstallation page says the database connection is already open, so there is nothing to connect.
| Function | WHMCS calls it | Returns |
|---|---|---|
_config | Module listed or configured | The config array. Required. |
_activate | Admin clicks Activate | status of success, error or info, plus a description |
_deactivate | Admin clicks Deactivate | The same three status values |
_upgrade | First access after the version changes | Nothing; passed the previous version |
_output | Module opened from the Addons menu | Nothing; it echoes the page |
_sidebar | With the admin page | Sidebar HTML as a string |
_clientarea | index.php?m=modulename | An array of output parameters |
The documented pattern for activation is a Capsule schema call inside a try/catch, returning an error status with the exception message. That error text is what an admin sees, so write it for them.
function billingsync_activate()
{
try {
Capsule::schema()->create('mod_billingsync_log', function ($table) {
/** @var \Illuminate\Database\Schema\Blueprint $table */
$table->increments('id');
$table->integer('invoice_id');
$table->text('response');
$table->timestamps();
});
return ['status' => 'success', 'description' => 'Set the API key, then run a test sync.'];
} catch (\Exception $e) {
return ['status' => 'error', 'description' => 'Could not create the log table: ' . $e->getMessage()];
}
}
The documentation is direct about the matching half: deactivation should undo everything activation does. I drop my own tables with dropIfExists but leave anything a client would miss, because deactivation is often a diagnostic step and not a goodbye. WHMCS warns admins from the other side: disabling a module may delete data.
The upgrades page explains the version mechanism: the upgrade function runs the first time the module is accessed after the version number in the config array changes, and receives the installed version in $vars['version']. Write one if per release, so a site two versions behind catches up in one pass.
How do you build the admin page?
With the _output function, which echoes HTML rather than returning it. The admin area output page is specific: WHMCS captures what you echo and places it inside the Admin Area template.
$vars carries every configuration field with its saved value, the module version, the language array as _lang, and modulelink, the URI back to your module in the form addonmodules.php?module=xxxxxx. Build links by appending your own query string to it, and use POST forms for input. Inside the function you read $_GET and $_POST directly, and $_SESSION['adminid'] gives the logged-in staff ID to look up in tbladmins.
Past one screen, use the shape the sample module shows: read an action from the request, hand it to a dispatcher class in lib/, echo what it returns.
How do you add a client area page?
With the _clientarea function, which returns an array instead of echoing. The client area output page lists the keys, and the page is reached at index.php?m=modulename.
| Key | What it sets |
|---|---|
pagetitle | The page title |
breadcrumb | An array of URL to label pairs |
templatefile | A template in the module folder, without the .tpl |
requirelogin | True sends anonymous visitors to the login page |
forcessl | True or false |
vars | Variables the template can use |
A return naming 'templatefile' => 'clienthome' expects clienthome.tpl in the module folder, and the module's language strings are available there too. Set requirelogin to true for anything showing client data, and do not rely on it alone: check in code that the logged-in client owns the record asked for. If a client page is the whole job, my WHMCS custom page guide compares this route with a standalone PHP file in the WHMCS root.
Where does an addon module keep its own data?
In its own tables, created in _activate and reached through Capsule. The database interaction page describes the layer WHMCS has shipped since 6.0: a query manager at Capsule::table(), a schema manager at Capsule::schema(), and PDO through Capsule::connection().
Four rules come straight off that page. Capsule escapes all input, so values passed to its methods need no escaping slashes. Every Capsule method throws an exception on failure, so every call belongs in a try/catch. The older helpers select_query(), update_query(), insert_query() and full_query() still exist but are deprecated and may be removed. And WHMCS does not recommend changing the schema of its own tables, which is the fastest way to break an update.
My rule on top: prefix every table with mod_ and the module name, as the sample does with mod_addonexample. When a query misbehaves, getQueryLog() returns the request's queries with their bindings, and uncaught failures reach the Activity Log.
How do hooks fit into an addon module?
They go in a file called hooks.php in the module folder. The addon hooks page says WHMCS detects that file and loads its hooks on every page, with the functions written exactly as in a standalone hook file.
The file loads on every page once the module is active, so slow code in a frequently fired hook is a site-wide cost. The hooks also travel with the module, which is why I put hooks inside a module even when it has no admin page. The module hooks page adds the detail that catches people out: hook files are detected when the module is activated, so a hooks.php added later needs the module's settings saved again before WHMCS sees it.
Who can open the module after you activate it?
Only the administrator roles ticked under Access Control. The WHMCS Addon Modules page gives the sequence: upload the files to /modules/addons, click Activate, click Configure, fill in the settings, select the administrator roles under Access Control, then Save Changes. The module appears in the Addons menu after that.
Check Access Control before you check your code: a module with no role ticked is invisible and logs no error. My module installation guide covers the activation path for every module type.
What do the WHMCS 9 escaping and template rules require?
That your templates stop doing PHP, and that you escape your own output. The 9.0 release notes record the move to Smarty 4.0 and the removal of the fetch, php, include_php and smarty_template.object tags, plus the legacy Smarty PHP tags deprecated in 8.7. They also set the floor at PHP 8.2, with 8.3 recommended and a matching ionCube Loader.
The Smarty Security Policy page is the one to read before writing a template. The policy allows no calls to static classes, no fetching of data from PHP streams and no access to super global variables, and the system policy restricts the same four tags. One exception on that page matters: the system policy still enables the get, post, server and request special Smarty variables for compatibility with older templates. Build as if they were off and put what a template needs into the vars array from your PHP, where you can validate it first. The mail policy allows the escape, count, urlencode, ucfirst and date_format modifiers by default.
On input, the division is clear. Capsule escapes the values you pass to a query, so database writes are covered. Nothing in the addon module documentation says WHMCS escapes $_GET or $_POST before _output reads them, and the sample module reads $_REQUEST['action'] raw. Treat every request value as untrusted: validate it against a known list, and escape it on the way out with htmlspecialchars() or the escape modifier. Admin pages are not the place to skip this.
One more rule makes upgrades survivable: a site owner can override your templates without editing your files, by copying one into /templates/theirtheme/modules/addons/yourmodule/, as the Custom Modules page describes. Say which files are safe to override. If you are still on 8.13 or 9.0, my WHMCS 9 upgrade guide covers the move.
How do you test the module before you ship it?
On a staging copy, through every path an admin and a client can take, including the ones that fail. The sample module ships a PHPUnit setup, and WHMCS recommends unit tests.

The list I work through before a module leaves staging:
- Activate on a clean install and confirm the table appears with the right columns.
- Activate twice: the second attempt must fail readably, not fatally.
- Deactivate, activate again, and check no data is orphaned.
- Raise the version number and confirm
_upgraderuns once and only once. - Open the admin page as a role not ticked in Access Control.
- Open the client page logged out, and as a client who does not own the record.
- Break the credentials on purpose and read what the page says.
One limit is worth stating plainly: an addon module is not a billing engine, and code that runs a service lifecycle from one rebuilds what a provisioning module gives for free. Cost is answered in my module development cost guide.
What else do people ask about WHMCS addon module development?
Why is my addon module not showing in the Addons menu?
Check Access Control first: a module with no administrator role ticked is invisible to everyone, with no error anywhere. Then check the folder sits directly in /modules/addons, the main file name matches the folder exactly, and both are lowercase, since Linux file systems are case sensitive.
Does a WHMCS addon module need its own database tables?
No. Many addon modules only read WHMCS data or call an outside API, and the config fields already store settings. Create a table when you have records of your own to keep, in _activate, so the module installs itself.
Is an addon module the same as a WHMCS hook?
No. A hook is a function in /includes/hooks/ that runs on a named event, with nothing to activate and no settings screen. An addon module is activated, has a settings form and access control, and can carry its own hooks. Use a hook for a reaction, an addon module when staff need settings.
Can I build custom addon modules on WHMCS Cloud?
No. The Custom Modules documentation states that custom modules apply to self-hosted installations and that WHMCS Cloud does not currently support them. On Cloud, the first decision is whether to move to self-hosted.
If you want this built rather than described, I take addon module work as custom WHMCS module development, or by the hour as a freelance WHMCS developer, with a free scoping call of about 30 minutes and a quote within one business day. All sales are final, so ask me everything before you buy.
Last reviewed 2 December 2026. Disclosure: I sell custom WHMCS module development, so I am not neutral. I am CTO at ElySpace, a freelance developer for Marmaids LLC, and founder of WHMCSPilot and MagizAI. I am not affiliated with WHMCS.