Jump to content

Hook in Server Module are not added


sotto

Recommended Posts

I have a `hooks.php` inside a otherwise working Server/Provisioning Module and none of the added hooks are working.

I added this simple hook to verify it:

```php

add_hook('ClientLogin', 1, function($vars) {

logModuleCall('server module', 'testhook');

});

```

...nothing's logged.

 

I was beginning to think, that Module Hooks are not allowed in Server Modules but the [sample Provisioning Module]{https://github.com/WHMCS/sample-provisioning-module/blob/master/modules/servers/provisioningmodule/hooks.php) suggests they are.

 

What am I missing?

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...
  • 3 months later...
Have you updated the hooks to work with WHMCS 7.2.2? There were some major changes with the introduction of 7.x

 

This is the only code in the hook file. Can't imagine it's outdated. Nothing get's logged in the module log. I should add that I tried adding that hook to the "includes/hooks/example.php" file and it worked. I also have an addon module on the WHMCS installation, and it's hooks are working fine too. Seems to be just the provisioning module.

 

<?php
if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

add_hook('EmailTplMergeFields', 1, function ($params) {
   return array(
       'multicraft_server_id'=>'Multicraft Server ID',
   );
   logModuleCall('server module', 'testhook');
});

Link to comment
Share on other sites

I experience the same as you dylanhansch. I tested it in "includes/hooks/example.php" and the code worked as expected. However, it does not work when inside my hooks.php for provisioning module.

 

<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

add_hook('ClientAreaPrimarySidebar', 1, function($primarySidebar) {
//$primarySidebar->getChild("Service Details Overview")->getChild("Information")->setLabel("Hello");
$primarySidebar->getChild("Service Details Overview")->addChild('World', array('uri' => '#', 'order' => 15));

});

 

Submitted a support ticket with WHMCS.

Link to comment
Share on other sites

Just to mention that addons, registrar modules and server modules hooks are cached. This said, if you have a module active and then you add hooks.php to the module folder, then the hookpoints from the hooks.php file wont be loaded. It is compulsory to do a save changes action on any of the products setup using the module for which you have added the hooks.php file

 

Hope this helps.

Link to comment
Share on other sites

Just to mention that addons, registrar modules and server modules hooks are cached. This said, if you have a module active and then you add hooks.php to the module folder, then the hookpoints from the hooks.php file wont be loaded. It is compulsory to do a save changes action on any of the products setup using the module for which you have added the hooks.php file

 

Hope this helps.

 

Thank you - that's very helpful to know. Annoying to work with though *sigh*. Is that even mentioned anywhere in the docs, or am I missing something?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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