|
|
(16 intermediate revisions by 4 users not shown) |
Line 1: |
Line 1: |
− | Action hooks allow you to add your own code that will run when specific actions occur in WHMCS. For example, this can be used for things like performing other actions when an order is placed, sending an SMS message when a support ticket is opened, updating a users details in another application when a change is made in WHMCS, and many more...
| + | <div class="docs-alert-info"> |
− | | + | <span class="title">Note</span><br /> |
− | ==How It Works== | + | This page has moved to [https://developers.whmcs.com/hooks/ https://developers.whmcs.com/hooks/] |
− | | + | </div> |
− | Hooks work by creating a file in the includes/hooks folder. Within the file, you need to declare a function that performs the action you want to run. That function will be passed variables from WHMCS, and the values you get depend on the hook being called. All hooks and the variables they will be passed are listed below. After defining your function, you then add the hook to WHMCS which is done by calling the add_hook function:
| |
− | | |
− | function create_forum_account($vars) {
| |
− | print_r($vars);
| |
− | }
| |
− | add_hook("ClientAdd",1,"create_forum_account");
| |
− | | |
− | *The first part defines the hook point. This must be one of the hook points in the categories below: ClientAdd, AddInvoicePayment, TicketOpen, etc...
| |
− | *The number defines the priority so if you have more than 1 hook for the ClientAdd function, the order in which the hooks should run
| |
− | *The third argument tells WHMCS which function to run at this hook point and so this is the name of the function which you have written in your hook file
| |
− | | |
− | A commented out example hook file is included in WHMCS which you can use as a template. You'll find that in the folder /includes/hooks/
| |
− | | |
− | ==Hook Points==
| |
− | | |
− | Hooks are divided up into categories to help make it easier to find exactly what you're looking for. So simply choose a category from below to see the hooks which exist for that, details of when they run and what variables they are passed.
| |
− | | |
− | {{Hook_Categories}}
| |