Given that I have a WHMCS addon that I call ‘my_addon’. I created the main addon file 'my_addon.php'
which does contain nothing than:
<?php function my_addon_clientarea($vars) { $client = null; return array( 'pagetitle' => 'My Addon', 'breadcrumb' => array('index.php?m=my_addon'=>'My Addon'), 'templatefile' => 'views/myaddon_view', 'vars' => array( 'client' => $client ) ); }
This does basically work. It does give me my template file, everything is passed through. My question is: How do I get the currently logged in client from within that function?
I didn’t find any API method and I can’t see any constant which does hold this information.
There must be a way to get the current client within the clientarea? Thanks for your help!
Advertisement
Answer
For those who do come after me and have the same problem: it’s easy to solve. Turned out, that I just had to think it through… I found the client id to be available in the $_SESSION
-variable.
So, if you are looking for the client’s id:
<?php function my_addon_clientarea($vars) { $clientid = $_SESSION['uid']; // And so on... }