{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Getting Started","description":"Developer documentation for the WHMCS API — the","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"getting-started","__idx":0},"children":["Getting Started"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following steps demonstrate how to create a hook function in WHMCS."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"create-your-hook-file","__idx":1},"children":["Create your Hook File"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Hooks in WHMCS exist in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/includes/hooks/"]}," directory. Alternately, they may be within a module (for more information, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/hooks/module-hooks/"},"children":["Module Hooks"]},")."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The example process below creates a WHMCS hook."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1-create-the-hook-file","__idx":2},"children":["1. Create the Hook File"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["helloworld.php"]}," file in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/includes/hooks/"]}," directory:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"touch ~/includes/hooks/helloworld.php\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To exclude a hook file from execution, prefix the filename with an underscore (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["_"]},")."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"2-add-the-hook-function","__idx":3},"children":["2. Add the Hook Function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add the hook code to the new ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".php"]}," file. Hook functions can be either named functions or closures."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For an example of hook code, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/hooks/sample-hook"},"children":["Sample Hook"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Hook functions can be either named functions or closures."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When the hook code runs, the system will pass a selection of variables to your hook point. The variables you receive will depend on the invoked action and the data that is available to it."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Some hook points will also allow you to return values. In some cases, the response you provide can override default behaviours."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When using a named function, prefix your function name with something unique to you and your code in order to prevent naming conflicts."]}]}]},"headings":[{"value":"Getting Started","id":"getting-started","depth":1},{"value":"Create your Hook File","id":"create-your-hook-file","depth":2},{"value":"1. Create the Hook File","id":"1-create-the-hook-file","depth":2},{"value":"2. Add the Hook Function","id":"2-add-the-hook-function","depth":2}],"frontmatter":{"title":"Getting Started","seo":{"title":"Getting Started"}},"lastModified":"2026-08-03T17:00:42.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/hooks/getting-started","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}