Custom Modules

In WHMCS, provisioning, addons, and payment gateways all use modules to interact with third-party systems or otherwise automate your business’s activities. For example, if you accept payments through Stripe™, you use the Stripe module. In addition to the many modules that WHMCS includes by default, you can add third-party modules or customize your own.

Module Templates

Modules in WHMCS use templates to define and control the output that users see. You can customize module templates using an overrides system that allows customizations within your active Client Area theme directory.

  • When you use this system, updates will not overwrite your custom modules.
  • Module template files can exist in either the root directory of the module or in a templates subdirectory.

Create an Override Template

To create an override template, copy the original template file within the following directory structure inside your custom template:

/templates/yourtemplatename/modules/moduletype/modulename/

In this directory structure, yourtemplatename is the name of your template, moduletype is the type of module (for example, server), and modulename is the module name.

For example:

  • For the cpanel server provisioning module, you could customize the /modules/servers/cpanel/templates/overview.tpl file by creating the following template file: /templates/example/modules/servers/cpanel/overview.tpl
  • For the licensing provisioning module, you could customize the /modules/servers/licensing/templates/managelicense.tpl file by creating the following template file: /templates/example/modules/servers/licensing/managelicense.tpl
  • For the Client Area view template of the Project Management addon, you could customize the /modules/addons/project_management/templates/clientview.tpl file by creating this template file: /templates/example/modules/addons/project_management/clientview.tpl

Version-Specific Templates

Modules can also provide templates that work with specific Client Area themes.

In WHMCS 8.1 and higher, for example, there are two themes included by default: Twenty-One and Six. Six implements the Bootstrap 3 framework, while Twenty-One uses Bootstrap 4. Because of differences in how they apply styling and structures, a template that works for one may not work for the other.

This allows you to define a default template that has additional templates to use in conjunction with specific system themes. For example, this could provide an older Bootstrap 3-compatible template for use with Six.

For more information about using version-specific templates, see our Developer Documentation.

Customize Ports in Server Modules

To add support for port customization to your server or provisioning modules, define the defaults within the MetaData function.

The following example provides a custom module with a default port of 80 and an SSL port of 443:

    function template_MetaData()
    {
        return array(
            'DisplayName' => 'Server Module Display Name',
            'DefaultNonSSLPort' => '80',
            'DefaultSSLPort' => '443',
        );
    }

    function template_CreateAccount($params)
    {
        $serverPort = $params['serverport'];
    }

Last modified: October 25, 2024