Extending Further

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 yourmodulename_, 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 yourmodulename_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 yourmodulename_ClientAreaCustomButtonArray() {
    return array(
        "Push Domain" => "push",

The key value of the array is what is 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: