How can we improve WHMCS?

Share, discuss and vote for what you would like to see added to WHMCS

Hook return issues including more then one hook point compatibility and changes to smarty variables

  • aisonet shared this idea 3 years ago
  • Developers
  • 4 Comments


The issue at hand here is what happens with the return data from a hook point. I want it to be official that a hook can change smarty template variables so that changes to the default WHMCS templates can be made without editing the included WHMCS templates. This will allow the WHMCS updater to update whmcs and the default templates, while being able to make basic changes to the template by changing the smarty templates sent to the template. Making changes to smarty/template/whmcs variables from within a hook, allows for code changes of a template without having to modify the WHMCS provided template, thus when updates come out, the templates stay up to date without merging/fixing of custom changes.

When you change the smarty templates via hook return data, having more then one hook using the hook point (for example ClientAreaPage) even with different priorities, to change whmcs variables including smarty template variables in the array that is passed to the hook function does not work as one would assume. The array argument getting passed to any subsequent hook for the same hook point is getting reset and any changes made in the first hook function results do not get passed into any subsequent hook function.

When the first hook (by priority) changes one variable for hook point example ClientAreaPage and then another hook changing a completely different variable for hook point example ClientAreaPage, the highest priority hook return variables are the only ones changed, and any lower priority hook variables are not changed at all. Thus the subsequent hooks do nothing to template or whmcs variables, while only highest priority hook actually preforms as indented and can adjust the built in whmcs variables and smarty template variables.

This behavior would occur in any third party module when you have module A calling hook ClientAreaPage to change variable A and then another third party module B calling hook ClientAreaPage to change variable B. Only the hook point with the highest priority would be able to change any whmcs variables passed to the function and would show on the template where as the lower priority would not.

The ability of merging the results of more then one hook calling the same hook point allows both to set variables if needed. The lowest priority hook changes what variables it needs, and subsequent hooks see the all the whmcs variables including the previous hooks changes/additional variables made. This ability for example allows one hook to change the logo and another other hook to change the company for example, both work. In your current code, if the hook that changes the company is higher then the hook that changed the logo, then the logo change doesnt work, only the company change goes to the template from the higher hook.

So to summarize, I would like the ability for hook result variable merging and official support of whmcs and smarty template variables changing (not just additional variables) to allow more programmer flexibility including when more then one hook file calls the same hook point to change variables (not just add additional variables).

4 Comments

Login to post a comment.

If the company change hook is higher than the logo change hook, then the logo change hook will not be applied to the template; only the company change hook will be applied. Geometry Dash has an autonomous square. To jump when needed and control vehicles, simply click and hold the up and down buttons. https://geometrydashwave.com
It’s encouraging to see the WHMCS community, including https://www.tech24inc.com/, actively engaging with the platform’s development through such detailed feature requests. These discussions around hook point compatibility and enhancements to Smarty variables are crucial for evolving the functionality and user experience!
If necessary, both hooks can set variables simultaneously by merging the results of their calls to the same hook point, all of the whmcs variables, including those of the preceding hooks
https://geometry-dashfree.com/
The variables returned by the highest priority hook are the only ones modified; all lower priority hook variables remain unchanged. Another hook modifies an entirely other variable for the hook point, such as ClientAreaPage. As a result, only the highest priority hook truly functions as an indent and has the ability to modify both smarty template variables and built-in whmcs variables. Subsequent hooks do nothing with template variables or whmcs variables. https://geometrydash-subzero.io