This service has been discontinued

If you are a company selling whmcs modules and you are interested in our code you can contact us with an offer at info at whmcstricks dot com
All other requests will be ignored.

Custom module to manage hooks settings

January 20, 2020

We manage multiple WHMCS installations, all with our hooks. Every time we need to upgrade an hook it is necessary to check the old one, change the settings, then upload it.

In the past we made a setting file with a big array for every WHMCS installation, but that way is still suboptimal. We had many errors.

So we decided to create a module that will store the settings in the database. This way the files are exactly the same for every installation, and when we need to update something all we have to do is to upload the new files, and everything will work perfectly.

Download Now

To install this copy the "hooks_settings" folder and its content inside WHMCS/modules/addons.

Then from the admin area go on Setup -> AddonModules

whmcs hooks settings module

Then activate the module and configure it to give access to the admin groups you prefer

whmcs hooks settings module activate access

The module is now functional. It is extremely easy to use, but let's see it together. First of all we have to access the module page from Addons -> WHMCS Tricks Hooks Settings

Will see a form and a list of all the existing settings.

Please note that both fields in the form have to be filled, you can't save an empty setting. Also note that the setting has to be unique to avoid confusion. The module will check for both this condition and send back an error if you make a mistake.

Once you add the settings you'll see them below and you will be able to delete or edit them.

Creating the settings

The module allows you to add the setting using a simple form. Just enter the setting and the value and click on "Save Changes" in the form. This allows you to create a setting for any hook you may want to use.

Custom module to manage hooks settings create setting

For our Custom Hooks you will see the setting below the form, and you can click on them to add them to the form. This will reduce the error, and give you some additional informations about the setting itself. Hovering over the information icon will open a tooltip with a brief description, while clicking on it will open the description page.

Custom module to manage hooks settings whmcstricks

Making it available for your own hooks

If you want to make the suggestions available for your own hooks, all you have to do is to create the "whmcstricks_config_" function. The code, as you can see below it's self-explanatory. All you have to do is to create a function with your setting name, and prepend "whmcstricks_config_" to the setting name.

Then add a text for the tooltip and a text for the description page.

function whmcstricks_config_jotform_authcode_id() {
return array(
'info' => 'tooltip text',
'description' => 'text for the description page. Supports HTML',

Retrieving the settings into the hooks

To use the settings you saved into the php code of your hooks is pretty easy.

you can decide to retrieve all the settings, or one at a time.

To get all the settings and put them into an array you should add this line of code as soon as you need the settings

$settings = whmcstricks_get_hooks_config();

It will then be accessible as an array using the setting as key and the value as value:

echo $settings['setting'];

You may also want to only get one setting, in this case you can use this code:

$setting = whmcstricks_get_hooks_config('setting');
Download Now

Got questions or problems? Contact us or comment, we'll be happy to help.

6 comments on “Custom module to manage hooks settings”