Difference between revisions of "Registrar Module Developer Docs"

From WHMCS Documentation

(DOCS-6345)
Line 1: Line 1:
'''Registrar Modules''', also referred to as '''Domain Modules''', allow you to create modules to allow for the registration and management of domains in WHMCS.
+
Registrar Modules allow for the registration and management of domains within WHMCS.
  
The core functionality of a registrar module is for registering, initiating transfers, performing renewals & allowing for the viewing and changing of both nameservers and WHOIS information for those domainsBut they can do a whole lot more if you want them to.
+
Registrar Modules are also referred to as '''Domain Modules'''.
 +
 
 +
The core functionality of a registrar module will allow for  
 +
 
 +
* registering domains
 +
* initiating transfers
 +
* performing renewals
 +
* allow the viewing and changing of nameservers
 +
* allow the viewing and changing of WHOIS information for those domains
 +
 
 +
But they can do a whole lot more if you want them to.
  
 
{{Developer_Links}}
 
{{Developer_Links}}
  
  
Other types of modules that can be created in WHMCS are [[Gateway Module Developer Docs|Payment Gateways]], [[Provisioning Module Developer Docs|Provisioning Modules]] and [[Addon Module Developer Docs|Addons]].
+
There are other types of module in WHMCS. These are [[Gateway Module Developer Docs|Payment Gateways]], [[Provisioning Module Developer Docs|Provisioning Modules]] and [[Addon Module Developer Docs|Addons]].
  
 
==Getting Started==
 
==Getting Started==
  
Begin by downloading the Registrar Module Template file for sample code to refer to here: http://www.whmcs.com/members/dl.php?type=d&id=16
+
Begin by downloading the Registrar Module Template: http://www.whmcs.com/members/dl.php?type=d&id=16
  
 
===Naming Conventions===
 
===Naming Conventions===
  
Registrar Modules are stored in the '''/modules/registrars/''' directory. The module name you choose must be unique, and should be all lowercase, containing only letters & numbers, always starting with a letter.
+
Registrar Modules are found in the /modules/registrars/ directory. The module name chosen must be unique and should be all lowercase. The name must only contain letters & numbers whilst always starting with a letter.
  
Within the module itself, all functions must then be prefixed with the module filename, followed by an underscore, and then the function name. For example if your module was called "mymodule" the register function would be named "mymodule_RegisterDomain".
+
Inside the module, function naming will follow a certain format. Functions have a prefix of the module filename, underscore, then the function name. For example, a module "mymodule" would have the register function "mymodule_RegisterDomain".
  
 
===Product Configuration Options===
 
===Product Configuration Options===
  
As with all module types in WHMCS, the required function of all provisioning modules is the configuration function. This is what defines the settings that can be configured for this registrar module within the WHMCS Admin Area. The name of this function must be '''mymodule_getConfigArray''' matching the name of your module.
+
As with all modules in WHMCS, the required function is the configuration function. This defines the settings that are available on a registrar basis when a domain uses the module. The name of this function must be mymodule_getConfigArray matching the name of your module.
  
The supported field types are '''Text, Password, Yes/No Checkboxes, Dropdown Menus, Radio Buttons & Text Areas'''
+
There is a limited number of supported field types. These are: Text, Password, Yes/No Checkboxes, Dropdown Menus, Radio Buttons & Text Areas .
  
 
Below are examples of the available parameters for each field type. Registrar modules support an unlimited number of options defined in this way.
 
Below are examples of the available parameters for each field type. Registrar modules support an unlimited number of options defined in this way.
Line 75: Line 85:
 
==Supported Functions==
 
==Supported Functions==
  
What follows here is a brief overview of all the possible functions that a product provisioning module in WHMCS can contain. All functions within a module are optional and can be omitted from the module if they don’t apply. Remember, within the code itself, all functions are prefixed with the module filename, followed by an underscore, and then the function name as shown in bold in these descriptions.
+
Here is an overview of all functions that a WHMCS registrar module can contain. Functions within a module are optional and need not be in the module if they don’t apply. Remember, all functions should have the prefix filename_ and then the function name. The function name is below in bold in the function descriptions.
  
*'''RegisterDomain''' - This function is called when the registration of a new domain is requested from WHMCS
+
*'''RegisterDomain''' - Called when the registration of a new domain comes from WHMCS
*'''RenewDomain''' - This function is called when a request to initiate the transfer of a domain is sent from WHMCS
+
*'''RenewDomain''' - Called when a request to renew a domain comes from WHMCS
*'''TransferDomain''' - This function is called when an existing domain is requested for renewal within WHMCS
+
*'''TransferDomain''' - Called when an existing domain transfer request comes from WHMCS
  
*'''GetNameservers''' - This function is called whenever a domains details are requested/viewed within WHMCS. It can return up to 5 nameservers that are set for the domain.
+
*'''GetNameservers''' - Called whenever a domain is viewed within WHMCS. It can return up to 5 nameservers that are set for the domain.
*'''SaveNameservers''' - This function is called when a change is made to the nameserver values displayed inside WHMCS.
+
*'''SaveNameservers''' - Called when a change request to the nameservers displayed inside WHMCS.
*'''GetRegistrarLock''' - This function is called whenever a domains details are requested/viewed within WHMCS. It should return the current lock status of a domain - either locked or unlocked.
+
*'''GetRegistrarLock''' - Called whenever a domains details are viewed within WHMCS. It should return the current lock status of a domain - either locked or unlocked.
*'''SaveRegistrarLock''' - This function is called when the lock status setting is toggled within WHMCS.
+
*'''SaveRegistrarLock''' - Called when the lock status setting is toggled within WHMCS.
*'''GetContactDetails''' - This function is called when the WHOIS information is requested to be viewed
+
*'''GetContactDetails''' - Called when the WHOIS information is displayed within WHMCS.
*'''SaveContactDetails''' - This function is called when revised WHOIS information is submitted
+
*'''SaveContactDetails''' - Called when revised WHOIS information is submitted
*'''GetDNS''' - This function is called when the DNS Host Records are requested to be viewed within WHMCS
+
*'''GetDNS''' - Called when the DNS Host Records are requested to be viewed within WHMCS
*'''SaveDNS''' - This function is called when any changes to DNS Host Records information is submitted
+
*'''SaveDNS''' - Called when any changes to DNS Host Records information is submitted
*'''IDProtectToggle''' - This function is called when the ID Protection setting is toggled on or off
+
*'''IDProtectToggle''' - Called when the ID Protection setting is toggled on or off
*'''GetEPPCode''' - This function is called when the EPP Code is requested for a transfer out
+
*'''GetEPPCode''' - Called when the EPP Code is requested for a transfer out
*'''ReleaseDomain''' - This function is called when a domain release is requested (eg. UK IPSTag Changes)
+
*'''ReleaseDomain''' - Called when a domain release is requested (eg. UK IPSTag Changes)
*'''RegisterNameserver''' - This function is called when a child nameserver is requested to be registered
+
*'''RegisterNameserver''' - Called when a child nameserver registration request comes from WHMCS
*'''ModifyNameserver''' - This function is called when a child nameserver is requested to be edited
+
*'''ModifyNameserver''' - Called when a child nameserver modification request comes from WHMCS
*'''DeleteNameserver''' - This function is called when a child nameserver is requested to be deleted
+
*'''DeleteNameserver''' - Called when a child nameserver deletion request comes from WHMCS
*'''RequestDelete''' - This function is called when a domain is requested to be deleted
+
*'''RequestDelete''' - Called when a domain deletion request comes from WHMCS
  
*'''ClientArea''' - This function can be used to define module specific client area output. It accepts a return of HTML for display on the domain details page of the client area. The output can alternatively be specified via a template file within the module folder named “clientarea.tpl” to allow for end user customisation. This function is discussed in more detail later on in the docs.
+
*'''ClientArea''' - Used to define module specific client area output. It accepts a return of HTML for display on the domain details page of the client area. Output via a template file within the module folder named "clientarea.tpl" is also possible. Discussion of this function in more detail later on in the docs.
*'''ClientAreaCustomButtonArray''' - This function can be used to define custom functions that your module supports that customers are allowed to invoke and run from the client area. These functions can just perform actions, or give domain page output in the client area, for example giving additional functionality available specific to your registrar.
+
*'''ClientAreaCustomButtonArray''' - Used to define custom functions that the module supports. Customers can invoke and run these from the client area. The functions can perform actions or product page output in the client area. Example usages for this are to provide domain management pages, bandwidth reporting pages, etc…
*'''ClientAreaAllowedFunctions''' - Similar to the above, this function can be used to define custom functions that customers are allowed to invoke themselves, but are not shown as buttons by default (ie. your custom client area output will invoke them)
+
*'''ClientAreaAllowedFunctions''' - Like the above, used to define custom functions. These are functions that customers can invoke, but are not shown as buttons by default. (i.e. custom client area output will invoke them).
  
== Domain Cron Sychronisation ==
+
== Domain Cron Synchronisation ==
  
Domain synchronization can be implemented into a registrar module to ensure domains in WHMCS stay in sync with the domain registrar. This can include syncing status changes, renewals, and expiry dates. This is particularly useful when it comes to transfers where completion of the transfer, and expiry dates can never be known by WHMCS automatically.
+
Implementation of domain sync into a registrar module ensures domains in WHMCS stay in sync with the registry. This can include syncing status changes, renewals, and expiry dates. This is particularly useful when it comes to transfers where completion of the transfer, and expiry dates can never be known by WHMCS automatically.
  
First let's look at Transfer Syncing. If present in your module, this function is called for every domain in the Pending Transfer status each time your domain sync cron runs. The function should then return either a true response for either completed or failed if the transfer has changed status since the last check. If failed, you can also return a reason. If there has been no change yet, then you should return nothing.
+
Let's look at Transfer Syncing. If present in your module, this function will run for every domain in the Pending Transfer status when the domain sync cron runs. The function should then return a true response for completed. Or a failed status if the transfer has changed status since the last check. If failed, you can also return a reason. If there has been no change yet, then you should return nothing.
  
 
<source lang = "php">
 
<source lang = "php">
Line 150: Line 160:
 
</source>
 
</source>
  
There there is regular Domain Syncing. If present in your module, then this function is called for 50 of the domains assigned to that module on a rolling basis each time the domain sync cron file runs. Once all domains have been synced it will start from the beginning again. This can be used to detect any changes done at registrars directly, such as changes to dates or statuses.
+
Then there is regular Domain Syncing. If present in your module, then this function runs for 50 of the domains for the module on a rolling basis each time the domain sync cron runs. Once all domains have synced it will start from the beginning again. This function can also detect any changes done at registrars directly, such as changes to dates or statuses.
  
 
<source lang = "php">
 
<source lang = "php">
Line 186: Line 196:
 
</source>
 
</source>
  
Settings relating to domain syncing can be found in the Setup > General Settings > Domains area. There are 3 key settings:
+
Settings relating to domain syncing are in the Setup > General Settings > Domains area. There are 3 key settings:
  
#'''Domain Sync Enabled''' - This must be ticked in order to allow the domain sync cron to actually run
+
# '''Domain Sync Enabled''' - Check to allow the domain sync cron to actually run
#'''Sync Next Due Date''' - This setting can be enabled if you want the syncronisation process to automatically update next due dates to match the same date as the expiry fields
+
# '''Sync Next Due Date''' - Enable this setting to update next due date to match the expiry field as part of the sync.
#'''Domain Sync Notify Only''' - This option is there if you want WHMCS to run the sync checks, and report any inconsisitencies to you, but not actually make any updates to the domains automatically. With this enabled you simply get an email report listing any discrepancies between data at the registrar and held in WHMCS.
+
# '''Domain Sync Notify Only''' - Enable this to allow WHMCS to run the sync checks and report any inconsistencies. But, no changes to the domains will occur. With this enabled you receive an email report listing any discrepancies between the registrar and WHMCS.
  
 
==Module Parameters==
 
==Module Parameters==
  
The module parameters are the data/values passed into each function when called. Every module function is passed the same core parameters - the settings of any fields defined in the configuration function above, along with the domainid, sld & tld to be managed. Additional variables will depend upon the function being called.
+
The module parameters are the data/values passed into each function when called. Every module function receives the same parameters. These parameters provide information about the specific domain the module command runs for. The parameters also contain the settings from the registrar itself. Extra variables may be available depending upon the function running.
  
 
<table width="100%" cellspacing="1" bgcolor="#cccccc">
 
<table width="100%" cellspacing="1" bgcolor="#cccccc">
Line 208: Line 218:
 
==Core Module Functions==
 
==Core Module Functions==
  
The core module functions are the '''Register, Transfer, Renew, GetNameservers, SaveNameservers, GetContactDetails & SaveContactDetails'''.  We recommend that all registrar modules should include these functions as a minimum.
+
The core module functions are the '''Register, Transfer, Renew, GetNameservers, SaveNameservers, GetContactDetails & SaveContactDetails'''.  We recommend that all registrar modules should contain these basic functions.
  
 
===Response Handling===
 
===Response Handling===
  
Many of the registrar modules are expected to return data. For example GetNameservers should return the nameservers for a domain, GetContactDetails should return the current WHOIS Info for a domain, etc... And therefore registrar module functions in WHMCS expect array based returns. Please refer to the sample module file template for specific details of what each function wants returning.
+
Many of the registrar module functions expect to return data. For example GetNameservers should return the nameservers for a domain. GetContactDetails should return the current WHOIS Info for a domain, etc... And so, registrar module functions in WHMCS expect array based returns. Refer to the sample module template for specific details of each function return.
  
 
===Success Handling===
 
===Success Handling===
Line 230: Line 240:
 
</source>
 
</source>
  
We particularly recommend using the GetNameservers function (which is called whenever a domains details are requested to be viewed) to return a friendly error when a domain is not yet registered. As admins will often view a domains details prior to registration, or during the timeframe of a transfer being processed. Something along the lines of "Domain Not Yet Registered" as opposed to "Error Domain Not Found" for example.
+
We recommend using the GetNameservers function to return a friendly error when a domain is not yet registered. Admins will often view a domains details before registration, or during the timeframe of a transfer process. Something like "Domain Not Yet Registered" as opposed to "Error Domain Not Found" for example.
  
 
==Custom Functions==
 
==Custom Functions==
  
Custom functions allow you to define additional operations that can be performed using the module. The custom functions can perform actions, or define additional client area pages/output. Permissions can be granted for who can use each custom function, be it just clients, just admins, or both.
+
Custom functions allow you to define extra operations that can be performed using the module. The custom functions can perform actions, or define extra client area pages/output. Permissions can be granted for who can use each custom function, be it just clients, just admins, or both.
  
The naming convention for custom functions follows the same as any other function within a module so it must begin with the module filename, followed by an underscore, and then the custom function name.
+
The convention for custom function names follow the same as any other function of a module. It must begin with the module filename_, and then the custom function name.
  
The easiest way to demonstrate this is with an example so let’s take an example of a Push Function that we want to give clients, that will make use of a template file called "pushdomain.tpl" within our custom registrar module folder.
+
The easiest way to show this is with an example. So let’s take an example of a Push Function that will use a template, "pushdomain.tpl":
  
 
<source lang="php">
 
<source lang="php">
Line 259: Line 269:
 
</source>
 
</source>
  
In the above you can see how the custom functions are defined, being passed all the same module parameters as all other functions, & returning an array response. The response can either be a simple empty array/error for an action function, or a complex array return like the above to define an additional client area page for additional domain management functionality.
+
The above shows how to define custom functions, use the parameters passed, and return an array response. The response can either be a simple empty array/error for an action function, or a complex array return like the above to define an extra client area page for extra domain management functionality.
  
Now we need to allow clients to use this. The following function defines that clients are allowed to invoke the push function, and will add a menu option to the Domain Actions dropdown within the client area for it.
+
Now we need to allow clients to use this. The following function defines that clients are allowed to invoke the push function, and will add a menu option to the Domain Actions dropdown within the client area for it.
  
 
<source lang="php">
 
<source lang="php">
Line 283: Line 293:
 
  </form>
 
  </form>
  
==Hooks (New for V5.0+)==
+
==Hooks==
  
Registrar modules can now also define hook functions, that can take effect system wide and allow registrar modules to integrate deeper into WHMCS more than ever before. For example you could have certain additional actions occurring when specific events occur in WHMCS, or simply use them to define a [[Widgets|Widget]] for use on the admin homepage to provide additional registrar specific functionality to the WHMCS admins/staff.
+
Registrar modules can now also define hook functions. The hooks can take effect system wide and allow registrar modules to integrate deeper into WHMCS more than ever before. For example you could have certain extra actions occurring when specific events occur in WHMCS. Or, use them to define a Widget for use on the admin homepage to provide extra registrar specific functionality to the WHMCS admins.
  
To create hooks that your module should define within WHMCS, you simply need to create a file named “hooks.php” within the custom registrar module folder, and that will then be automatically detected and any hooks loaded on every page of WHMCS.
+
Hooks that the module define are within the “hooks.php” file of the custom registrar module folder. This will then be detected and any hooks loaded on every page of WHMCS.
  
 
The hook functions within that file should be defined in exactly the same way as normal.
 
The hook functions within that file should be defined in exactly the same way as normal.
Line 295: Line 305:
 
==Module Logging==
 
==Module Logging==
  
As with all modules in WHMCS, we recommend you make use of the built in module logging functionality to aid both yourself, and end users should you plan to release your module publically, in debugging the calls your module makes in the same standardised way as all modules in WHMCS do by default. Please refer to the URL below for more details on how to do this.
+
As with all modules in WHMCS, we recommend you make use of the built in module logging functionality. This will aid both yourself, and end users should you plan to release the module. Debugging the calls the module makes in the same standardised way as all modules in WHMCS do by default. Please refer to the URL below for more details on how to do this.
  
 
http://docs.whmcs.com/Provisioning_Module_Developer_Docs#Module_Logging
 
http://docs.whmcs.com/Provisioning_Module_Developer_Docs#Module_Logging
  
 
==App Store==
 
==App Store==
WHMCS offers an app store to which your completed module can be submitted. The listings are displayed under the Addons tab within the administration area and online at http://www.whmcs.com/appstore . This is a great way to make WHMCS users aware of your module.
+
WHMCS offers an app store which accepts submission of the completed module. Displayed listings are found under the Addons tab within the administration area and online at http://www.whmcs.com/appstore . This is a great way to make WHMCS users aware of the module.
  
In order to submit a listing you'll need a login for whmcs.com/members, if you do not have one please [https://www.whmcs.com/members/submitticket.php?step=2&deptid=5 Contact Us]. Once logged in, visit the app store page at the above URL and click the "Submit your Addon" link. We aim to review submissions in 1-2 weeks.
+
Submission of a listing requires a login for whmcs.com/members, if you do not have one please [https://www.whmcs.com/members/submitticket.php?step=2&deptid=5 Contact Us]. Once logged in, visit the app store page at the above URL and click the "Submit your Addon" link. We aim to review submissions in 1-2 weeks.
  
  
 
{{Developer_Links}}
 
{{Developer_Links}}

Revision as of 13:08, 23 December 2015

Registrar Modules allow for the registration and management of domains within WHMCS.

Registrar Modules are also referred to as Domain Modules.

The core functionality of a registrar module will allow for

  • registering domains
  • initiating transfers
  • performing renewals
  • allow the viewing and changing of nameservers
  • allow the viewing and changing of WHOIS information for those domains

But they can do a whole lot more if you want them to.


There are other types of module in WHMCS. These are Payment Gateways, Provisioning Modules and Addons.

Getting Started

Begin by downloading the Registrar Module Template: http://www.whmcs.com/members/dl.php?type=d&id=16

Naming Conventions

Registrar Modules are found in the /modules/registrars/ directory. The module name chosen must be unique and should be all lowercase. The name must only contain letters & numbers whilst always starting with a letter.

Inside the module, function naming will follow a certain format. Functions have a prefix of the module filename, underscore, then the function name. For example, a module "mymodule" would have the register function "mymodule_RegisterDomain".

Product Configuration Options

As with all modules in WHMCS, the required function is the configuration function. This defines the settings that are available on a registrar basis when a domain uses the module. The name of this function must be mymodule_getConfigArray matching the name of your module.

There is a limited number of supported field types. These are: Text, Password, Yes/No Checkboxes, Dropdown Menus, Radio Buttons & Text Areas .

Below are examples of the available parameters for each field type. Registrar modules support an unlimited number of options defined in this way.

$configarray = array(
    "username" => array (
        "FriendlyName" => "UserName",
        "Type" => "text", # Text Box
        "Size" => "25", # Defines the Field Width
        "Description" => "Textbox",
        "Default" => "Example",
    ),
    "password" => array (
        "FriendlyName" => "Password",
        "Type" => "password", # Password Field
        "Size" => "25", # Defines the Field Width
        "Description" => "Password",
        "Default" => "Example",
    ),
    "usessl" => array (
        "FriendlyName" => "Enable SSL",
        "Type" => "yesno", # Yes/No Checkbox
        "Description" => "Tick to use secure connections",
    ),
    "package" => array (
        "FriendlyName" => "Package Name",
        "Type" => "dropdown", # Dropdown Choice of Options
        "Options" => "Starter,Advanced,Ultimate",
        "Description" => "Sample Dropdown",
        "Default" => "Advanced",
    ),
    "disk" => array (
        "FriendlyName" => "Disk Space",
        "Type" => "radio", # Radio Selection of Options
        "Options" => "100MB,200MB,300MB",
        "Description" => "Radio Options Demo",
        "Default" => "200MB",
    ),
    "comments" => array (
        "FriendlyName" => "Notes",
        "Type" => "textarea", # Textarea
        "Rows" => "3", # Number of Rows
        "Cols" => "50", # Number of Columns
        "Description" => "Description goes here",
        "Default" => "Enter notes here",
    ),
);
return $configarray;

Supported Functions

Here is an overview of all functions that a WHMCS registrar module can contain. Functions within a module are optional and need not be in the module if they don’t apply. Remember, all functions should have the prefix filename_ and then the function name. The function name is below in bold in the function descriptions.

  • RegisterDomain - Called when the registration of a new domain comes from WHMCS
  • RenewDomain - Called when a request to renew a domain comes from WHMCS
  • TransferDomain - Called when an existing domain transfer request comes from WHMCS
  • GetNameservers - Called whenever a domain is viewed within WHMCS. It can return up to 5 nameservers that are set for the domain.
  • SaveNameservers - Called when a change request to the nameservers displayed inside WHMCS.
  • GetRegistrarLock - Called whenever a domains details are viewed within WHMCS. It should return the current lock status of a domain - either locked or unlocked.
  • SaveRegistrarLock - Called when the lock status setting is toggled within WHMCS.
  • GetContactDetails - Called when the WHOIS information is displayed within WHMCS.
  • SaveContactDetails - Called when revised WHOIS information is submitted
  • GetDNS - Called when the DNS Host Records are requested to be viewed within WHMCS
  • SaveDNS - Called when any changes to DNS Host Records information is submitted
  • IDProtectToggle - Called when the ID Protection setting is toggled on or off
  • GetEPPCode - Called when the EPP Code is requested for a transfer out
  • ReleaseDomain - Called when a domain release is requested (eg. UK IPSTag Changes)
  • RegisterNameserver - Called when a child nameserver registration request comes from WHMCS
  • ModifyNameserver - Called when a child nameserver modification request comes from WHMCS
  • DeleteNameserver - Called when a child nameserver deletion request comes from WHMCS
  • RequestDelete - Called when a domain deletion request comes from WHMCS
  • ClientArea - Used to define module specific client area output. It accepts a return of HTML for display on the domain details page of the client area. Output via a template file within the module folder named "clientarea.tpl" is also possible. Discussion of this function in more detail later on in the docs.
  • ClientAreaCustomButtonArray - Used to define custom functions that the module supports. Customers can invoke and run these from the client area. The functions can perform actions or product page output in the client area. Example usages for this are to provide domain management pages, bandwidth reporting pages, etc…
  • ClientAreaAllowedFunctions - Like the above, used to define custom functions. These are functions that customers can invoke, but are not shown as buttons by default. (i.e. custom client area output will invoke them).

Domain Cron Synchronisation

Implementation of domain sync into a registrar module ensures domains in WHMCS stay in sync with the registry. This can include syncing status changes, renewals, and expiry dates. This is particularly useful when it comes to transfers where completion of the transfer, and expiry dates can never be known by WHMCS automatically.

Let's look at Transfer Syncing. If present in your module, this function will run for every domain in the Pending Transfer status when the domain sync cron runs. The function should then return a true response for completed. Or a failed status if the transfer has changed status since the last check. If failed, you can also return a reason. If there has been no change yet, then you should return nothing.

function modulename_TransferSync($params) {

# Your available parameters are:

    $params['domainid'];
    $params['domain'];
    $params['sld'];
    $params['tld'];
    $params['registrar'];
    $params['regperiod'];
    $params['status'];
    $params['dnsmanagement'];
    $params['emailforwarding'];
    $params['idprotection'];

# Other parameters used in your _getConfigArray() function would also be available for use in this function

# Put your code to check on the domain transfer status here

$values = array();

# - if the transfer has completed successfully

$values['completed'] = true; #  when transfer completes successfully
$values['expirydate'] = '2013-10-28'; # the expiry date of the domain (if available)

# - or if failed

$values['failed'] = true; # when transfer fails permenantly
$values['reason'] = "Reason here..."; # reason for the transfer failing (if available) - a generic failure reason is given if no reason is returned

# - or if errored

$values['error'] = "Message here..."; # error if the check fails - for example domain not found

return $values; # return the details of the sync

}

Then there is regular Domain Syncing. If present in your module, then this function runs for 50 of the domains for the module on a rolling basis each time the domain sync cron runs. Once all domains have synced it will start from the beginning again. This function can also detect any changes done at registrars directly, such as changes to dates or statuses.

function modulename_Sync($params) {

# Your available parameters are:

    $params['domainid'];
    $params['domain'];
    $params['sld'];
    $params['tld'];
    $params['registrar'];
    $params['regperiod'];
    $params['status'];
    $params['dnsmanagement'];
    $params['emailforwarding'];
    $params['idprotection'];

# Other parameters used in your _getConfigArray() function would also be available for use in this function


# Put your code to check on the domain status here

$values = array();

$values['active'] = true; # set to true if the domain is active
$values['expired'] = true; # or set to true if the domain has expired

$values['expirydate'] = '2013-10-28'; # populate with the domains expiry date if available

return $values; # return the details of the sync

}

Settings relating to domain syncing are in the Setup > General Settings > Domains area. There are 3 key settings:

  1. Domain Sync Enabled - Check to allow the domain sync cron to actually run
  2. Sync Next Due Date - Enable this setting to update next due date to match the expiry field as part of the sync.
  3. Domain Sync Notify Only - Enable this to allow WHMCS to run the sync checks and report any inconsistencies. But, no changes to the domains will occur. With this enabled you receive an email report listing any discrepancies between the registrar and WHMCS.

Module Parameters

The module parameters are the data/values passed into each function when called. Every module function receives the same parameters. These parameters provide information about the specific domain the module command runs for. The parameters also contain the settings from the registrar itself. Extra variables may be available depending upon the function running.

Var NameDescription
configvaluesthe settings defined in your modules configuration function - names as defined
domainidthe unique ID of the domain
Database Field: tbldomains.id
sldthe second level domain being managed (eg. google)
tldthe top level domain being managed (eg. .com)
regperiodthe registration period requested for the domain
nsXthe nameserver values for a domain - where X = 1 to 5

Core Module Functions

The core module functions are the Register, Transfer, Renew, GetNameservers, SaveNameservers, GetContactDetails & SaveContactDetails. We recommend that all registrar modules should contain these basic functions.

Response Handling

Many of the registrar module functions expect to return data. For example GetNameservers should return the nameservers for a domain. GetContactDetails should return the current WHOIS Info for a domain, etc... And so, registrar module functions in WHMCS expect array based returns. Refer to the sample module template for specific details of each function return.

Success Handling

Most of the functions within a registrar module have a set return. However, there are some that do not have a return value such as Register, Transfer and Renew. We recommend returning a success array so that the code can be read as being successful if up to this point:

return array("success" => true);

Error Handling

Should an error occur, you need to return a user friendly error message in an "error" return variable. For example:

return array( 'error' => 'Error Message Goes Here...' );

We recommend using the GetNameservers function to return a friendly error when a domain is not yet registered. Admins will often view a domains details before registration, or during the timeframe of a transfer process. Something like "Domain Not Yet Registered" as opposed to "Error Domain Not Found" for example.

Custom Functions

Custom functions allow you to define extra operations that can be performed using the module. The custom functions can perform actions, or define extra client area pages/output. Permissions can be granted for who can use each custom function, be it just clients, just admins, or both.

The convention for custom function names follow the same as any other function of a module. It must begin with the module filename_, and then the custom function name.

The easiest way to show this is with an example. So let’s take an example of a Push Function that will use a template, "pushdomain.tpl":

function mymodule_push($params) {

	$domainid = $params['domainid'];
	$sld = $params['sld'];
	$tld = $params['tld'];

	return array(
		'templatefile' => 'pushdomain',
		'breadcrumb' => array( 'clientarea.php?action=domaindetails&domainid='.$domainid.'&modop=custom&a=push' => 'Push Domain' ),
		'vars' => array(
			'var1' => 'valuehere',
			'var2' => 'anothervaluehere',
		),
	);

}

The above shows how to define custom functions, use the parameters passed, and return an array response. The response can either be a simple empty array/error for an action function, or a complex array return like the above to define an extra client area page for extra domain management functionality.

Now we need to allow clients to use this. The following function defines that clients are allowed to invoke the push function, and will add a menu option to the Domain Actions dropdown within the client area for it.

function mymodule_ClientAreaCustomButtonArray() {
    $buttonarray = array(
	 "Push Domain" => "push",
	);
	return $buttonarray;
}

The key value of the array is what get’s displayed to admins/clients on the button or menu options for the commands. And the value is the custom function name excluding the modulename_ prefix.

If you want to provide clients with a custom button or way to invoke a function, then this can be done as follows within a .tpl file described in the previous Client Area Output section:

<form method="post" action="clientarea.php?action=domaindetails">
<input type="hidden" name="domainid" value="{$domainid}" />
<input type="hidden" name="modop" value="custom" />
<input type="hidden" name="a" value="reboot" />
<input type="submit" value="Reboot VPS Server" />
</form>

Hooks

Registrar modules can now also define hook functions. The hooks can take effect system wide and allow registrar modules to integrate deeper into WHMCS more than ever before. For example you could have certain extra actions occurring when specific events occur in WHMCS. Or, use them to define a Widget for use on the admin homepage to provide extra registrar specific functionality to the WHMCS admins.

Hooks that the module define are within the “hooks.php” file of the custom registrar module folder. This will then be detected and any hooks loaded on every page of WHMCS.

The hook functions within that file should be defined in exactly the same way as normal.

Please refer to Hook Documentation for more info on creating and working with hooks in WHMCS.

Module Logging

As with all modules in WHMCS, we recommend you make use of the built in module logging functionality. This will aid both yourself, and end users should you plan to release the module. Debugging the calls the module makes in the same standardised way as all modules in WHMCS do by default. Please refer to the URL below for more details on how to do this.

http://docs.whmcs.com/Provisioning_Module_Developer_Docs#Module_Logging

App Store

WHMCS offers an app store which accepts submission of the completed module. Displayed listings are found under the Addons tab within the administration area and online at http://www.whmcs.com/appstore . This is a great way to make WHMCS users aware of the module.

Submission of a listing requires a login for whmcs.com/members, if you do not have one please Contact Us. Once logged in, visit the app store page at the above URL and click the "Submit your Addon" link. We aim to review submissions in 1-2 weeks.