Jump to content

register custom hooks


PixelPaul

Recommended Posts

is it possible to register/create a custom hook within my module for WHMCS. Not use one of the WHMCS hooks.

So people could assign functions to the hook to manipulate some data and return it back to my module after it executes the hook?

such as ...

<?php
add_hook('mymodule_myhook', 1, function($vars) {
    // Perform hook code here...
});

 

Edited by PixelPaul
Link to comment
Share on other sites

Yes. WHMCS has nothing to do with it. Place hook points in your code and create a sort of autoloader that runs functions if they are in use by your customers. You can also define what parameters you want to push and return.

The logic behind action hooks is not a proprietary thing of WHMCS. It can be applied to any scenario.

Link to comment
Share on other sites

  • 1 year later...

Yes this is possible, just use the function `run_hook` ie:

 

```

run_hook('MyCustomHook', array());

```

or

```

$return_value = run_hook('MyCustomHook', array());

```

 

Hooks are loaded via `includes/hookfunctions.php` and basically the cache is stored in `global $hooks'`. Not sure why WHMCS doesn't document this at all .. but then again i'm not surprised at all.  If i didn't have a decoded version of WHMCS i wouldn't be able to do 1/4 of the development work I do with WHMCS.

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