{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Authentication","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":"authentication","__idx":0},"children":["Authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following hooks are provided for Authentication related events."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"clientloginshare","__idx":1},"children":["ClientLoginShare"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Executes as part of client login if user does not exist."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters","__idx":2},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Variable"},"children":["Variable"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Notes"},"children":["Notes"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["username"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["password"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"response","__idx":3},"children":["Response"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Return data to create a user or refer to an existing client to be logged in as. id for existing user, email, boolean create to create new user, firstname, lastname etc to create a client."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"example-code","__idx":4},"children":["Example Code"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\nadd_hook('ClientLoginShare', 1, function($vars) {\n    // Perform custom authentication logic here\n    // There are 4 supported return values, each demonstrated below.\n\n    // User not found\n    return false;\n\n    // Login as existing WHMCS Client ID\n    return array(\n        'id' => '123',\n    );\n\n    // Login as existing WHMCS Client by Email Address\n    return array(\n        'email' => 'demo@whmcs.com',\n    );\n\n    // Create a new client and login\n    return array(\n        'create' => true,\n        'email' => 'demo@whmcs.com',\n        'firstname' => 'Demo',\n        'lastname' => 'User',\n        'companyname' => 'Demo Company',\n        'address1' => '123 Demo Street',\n        'address2' => '',\n        'city' => 'Demo',\n        'state' => 'Demo',\n        'postcode' => '12345',\n        'country' => 'US',\n        'phonenumber' => '11111111111',\n        'password' => 'xxxxxxxx',\n    );\n});\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"userlogin","__idx":5},"children":["UserLogin"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Executes when a user logs in."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-1","__idx":6},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Variable"},"children":["Variable"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Notes"},"children":["Notes"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["user"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["\\WHMCS\\User\\User"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"response-1","__idx":7},"children":["Response"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["No response supported"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"example-code-1","__idx":8},"children":["Example Code"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\nadd_hook('UserLogin', 1, function($vars) {\n    // Perform hook code here...\n});\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"userlogout","__idx":9},"children":["UserLogout"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Executes when a user logs out."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"parameters-2","__idx":10},"children":["Parameters"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Variable"},"children":["Variable"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Notes"},"children":["Notes"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["user"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["\\WHMCS\\User\\User"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"response-2","__idx":11},"children":["Response"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["No response supported"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"example-code-2","__idx":12},"children":["Example Code"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\nadd_hook('UserLogout', 1, function($vars) {\n    // Perform hook code here...\n});\n"},"children":[]}]},"headings":[{"value":"Authentication","id":"authentication","depth":1},{"value":"ClientLoginShare","id":"clientloginshare","depth":2},{"value":"Parameters","id":"parameters","depth":4},{"value":"Response","id":"response","depth":4},{"value":"Example Code","id":"example-code","depth":4},{"value":"UserLogin","id":"userlogin","depth":2},{"value":"Parameters","id":"parameters-1","depth":4},{"value":"Response","id":"response-1","depth":4},{"value":"Example Code","id":"example-code-1","depth":4},{"value":"UserLogout","id":"userlogout","depth":2},{"value":"Parameters","id":"parameters-2","depth":4},{"value":"Response","id":"response-2","depth":4},{"value":"Example Code","id":"example-code-2","depth":4}],"frontmatter":{"title":"Authentication","seo":{"title":"Authentication"}},"lastModified":"2026-08-03T17:00:42.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/hooks-reference/authentication","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}