2

After reading through the WHMCS documentation on hooks, I am still a little confused about where to begin to trigger custom code when a Product is suspended or terminated.

Here is an example of the code I have in a file in includes/hooks:

function hook_MyHookTest($vars) {
    mail('my@email.com', 'WHMCS Test', "This hook test was successful!\n\n" . date('r'));
}

add_hook('AfterModuleSuspend', 1, 'hook_MyHookTest');

In the Products/Services tab of the Client Profile, when I change the Status of the product from "Active" to "Suspended", nothing happens. I've used the function hook_MyHookTest with other hooks successfully, so I'm probably not understanding how AfterModuleSuspend is used.

Does another "Module" need to be created from scratch in order to use this hook?

Chris Ullyott
  • 303
  • 1
  • 12

1 Answers1

1

I found that hooks like AfterModuleSuspend and AfterModuleUnsuspend aren't accessible until installing a Provisioning Module into the WHMCS instance. Here's sample code for a module:

https://github.com/WHMCS/sample-provisioning-module

Chris Ullyott
  • 303
  • 1
  • 12