Jump to content

Question About Using Hooks


matts

Recommended Posts

We have WHMCS version 6 and are trialing a custom hooks to run the some reminder emails on free trial accounts.

 

Bit unsure if the documentation is saying the file in the folder /includes/hooks/ must be called hooks.php

 

http://docs.whmcs.com/Addon_Module_Developer_Docs

 

Can you please confirm this is the case the filename has to be hooks.php ?

 

Also is there an easy way to check that it has been run after the scheduled "DailyCronJob" thanks.

:)

Link to comment
Share on other sites

Bit unsure if the documentation is saying the file in the folder /includes/hooks/ must be called hooks.php

If you need to create ActionHooks file for your custom addon module your file should to be called hooks.php and its location is in your addon module directory /modules/addons/your-addon/hooks.php

 

but if you only need to create ActionHook file to make some changes in your WHMCS installation, then the file location is /includes/hooks/

and it can named anything.php

 

Can you please confirm this is the case the filename has to be hooks.php ?

answer above

 

Also is there an easy way to check that it has been run after the scheduled "DailyCronJob" thanks.

:)

you can use logActivity() function so your action hook will add record before or after task is completed

Link to comment
Share on other sites

Brilliant thanks for the answer. Understood now about the naming convention for hooks.

 

I have all the php for the module in the same file as the hook command (last line).

add_hook("DailyCronJob",1,"end_free_trials_hook");

 

So if I understand you correctly I can add

logActivity("end_free_trials_hook");

 

If so where am I looking for this log, not utilities > Logs > modules

Although I do have another module that is not functioning that I need help with adding logModuleCall syntax.

Link to comment
Share on other sites

let's say you ActionHook function is like the following, and at the end of the function logic we need to add log record:

 

<?php

function end_free_trials_hook($vars){

   // Your Code Logic


   logActivity("EndFreeTrials Function Completed.");
}
add_hook("DailyCronJob", 1, "end_free_trials_hook");

 

after the daily cron job process completed, your function will run and add new log record.

 

you can find those records in Utilities -> Logs -> Activity Log

Link to comment
Share on other sites

Very good I see so logActivity function puts a message after every run in menu Utilities -> Logs -> Activity Log.

 

As you seem to know about logs the modules / registrars / domainbox.php is giving errors it came from the Registrar.

I'm trying this to debug it ;

 

logModuleCall("domainbox","RegisterDomain","RegisterDomainResult","error");

 

Trying to get a verbose output to Utilities -> Logs -> Modules log

Link to comment
Share on other sites

here is the right syntax for the module log function from WHMCS module sample:

 

logModuleCall(
           (string) 'moduleName',
           (string) 'FunctionName',
           (array) $params,
           (string) "Error Message",
           ""
       );

 

- - - Updated - - -

 

also you need to "Enable Debug Logging" in Utilities -> Module Log, so it will save log records in DB when the "logModuleCall" function is called.

Link to comment
Share on other sites

  • 2 years later...
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated