Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 508 Vote(s) - 3.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WHMCS: How to get the current client in addon module clientarea page?

#1
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!
Reply

#2
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...
}
Reply

#3
The official way to get current user information is:

$currentUser = new \WHMCS\Authentication\CurrentUser;
$user = $currentUser->user();

You can find more information [here][1]


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through