{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Authentication via CurrentUser","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-via-currentuser","__idx":0},"children":["Authentication via CurrentUser"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WHMCS\\Authentication\\CurrentUser"]}," lets you assess the current state of authentication for the currently-logged-in user."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["WHMCS 8.0 added this functionality."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"methods","__idx":1},"children":["Methods"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The sample code below returns the authentication status for the person who is viewing the page containing that code. Note that none of these authentication states are mutually exclusive; it is possible (and sometimes likely) for the current user to return ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.whmcs.com/Users_and_Accounts"},"children":["Admin, User, and client account states"]}," simultaneously."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"isauthenticateduser","__idx":2},"children":["isAuthenticatedUser()"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a Boolean value indicating whether the current user is authenticated as a User."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, this:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\n\n$currentUser = new \\WHMCS\\Authentication\\CurrentUser;\nif ($currentUser->isAuthenticatedUser()) {\n    echo \"Current user authenticated as User.\";\n} else {\n    echo \"Current user not authenticated as User.\";\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Could return:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Current user not authenticated as User.\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"isauthenticatedadmin","__idx":3},"children":["isAuthenticatedAdmin()"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a Boolean value indicating whether the current user is authenticated as an Admin."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, this:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\n\n$currentUser = new \\WHMCS\\Authentication\\CurrentUser;\nif ($currentUser->isAuthenticatedAdmin()) {\n    echo \"Current user is authenticated as Admin.\";\n} else {\n    echo \"Current user is not authenticated as Admin.\";\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Could return:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Current user is not authenticated as Admin.\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ismasqueradingadmin","__idx":4},"children":["isMasqueradingAdmin()"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a Boolean value indicating whether the current user is authenticated as an Admin who is acting on behalf of a user. This occurs after an Admin clicks ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Login as Owner"]}," in the client profile."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, this:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\n\n$currentUser = new \\WHMCS\\Authentication\\CurrentUser;\nif ($currentUser->isMasqueradingAdmin()) {\n    echo \"Current user is a masquerading Admin.\";\n} else {\n    echo \"Current user is not a masquerading Admin.\";\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Could return:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Current user is a masquerading Admin.\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"user","__idx":5},"children":["user()"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WHMCS\\User\\User"]}," object that indicates the currently-authenticated User. You can use this according to the class documentation."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]}," if the current user isn't authenticated as a User."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, this:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\n\n$currentUser = new \\WHMCS\\Authentication\\CurrentUser;\n$user = $currentUser->user();\nif ($user) {\n    echo \"There is an authenticated User, and their name is {$user->fullName}.\";\n} else {\n    echo \"There is not an authenticated User.\";\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Could return:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"There is an authenticated User, and their name is Jane Doe.\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"admin","__idx":6},"children":["admin()"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WHMCS\\User\\Admin"]}," object that indicates the currently-authenticated Admin. You can action on this according to the class documentation."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]}," if the current user isn't authenticated in the Admin Area (for example, if they are a User)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, this:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\n\n$currentUser = new \\WHMCS\\Authentication\\CurrentUser;\n$admin = $currentUser->admin();\nif ($admin) {\n    echo \"There is an authenticated Admin, and their name is {$admin->fullName}.\";\n} else {\n    echo \"There is not an authenticated Admin.\";\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Could return:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"There is an authenticated Admin, and their name is Jane Doe.\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"client","__idx":7},"children":["client()"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WHMCS\\User\\Client"]}," object that indicates the currently-authenticated client account. You can action on this according to the class documentation."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]}," if the current user isn't authenticated as a client account (for example, if they are not authenticated in the Client Area)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, this:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"<?php\n\n$currentUser = new \\WHMCS\\Authentication\\CurrentUser;\n$client = $currentUser->client();\nif ($client) {\n    echo \"There is an authenticated Client, and their name is {$client->fullName}.\";\n} else {\n    echo \"There is not an authenticated Client.\";\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Could return:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"There is an authenticated Client, and their name is Jane Doe.\n"},"children":[]}]},"headings":[{"value":"Authentication via CurrentUser","id":"authentication-via-currentuser","depth":1},{"value":"Methods","id":"methods","depth":2},{"value":"isAuthenticatedUser()","id":"isauthenticateduser","depth":3},{"value":"isAuthenticatedAdmin()","id":"isauthenticatedadmin","depth":3},{"value":"isMasqueradingAdmin()","id":"ismasqueradingadmin","depth":3},{"value":"user()","id":"user","depth":3},{"value":"admin()","id":"admin","depth":3},{"value":"client()","id":"client","depth":3}],"frontmatter":{"title":"Authentication via CurrentUser","seo":{"title":"Authentication via CurrentUser"}},"lastModified":"2026-08-03T17:00:42.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/advanced/authentication","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}