Jump to content

Get client id


MACscr

Recommended Posts

I am adding some additional pages to the client area and was wondering how i could get the user id or clientname of the currently logged in user. Any ideas? This is probably only something that Matt can answer, but i figured others might want to know as well.

Link to comment
Share on other sites

  • WHMCS CEO
ok, then why doesnt your sample page addition code work?

Yes, it does - glad you got it working.

 

Possible to find out if admin is logged in?

You can use $_SESSION['adminloggedinstatus'] to see if the admin is logged in.

Link to comment
Share on other sites

I set up some smarty plugins to gather this info and other info, I can at least tell you how I did it...

 

$_SESSION['uid'] is what session variable stores the currently logged in User ID and you can then use that to get almost any info about the client whenever a variable is not available, ie...

 

if ($_SESSION['loggedinstatus']=="true") {

 $client_info = mysql_fetch_all("SELECT firstname, lastname, companyname FROM tblclients WHERE userid = ".$_SESSION['uid']);

 if (count($client_info)) {
   $firstname = $info[0]['firstname'];
   $lastname = $info[0]['lastname '];
   $companyname= $info[0]['companyname'];
 }
}

 

If you are doing this inside the WHMCS systm, the DB connection should have already been opened by the WHMCS headers and code, so all you need to do is request the info.

 

Hope that helps!

Link to comment
Share on other sites

I set up some smarty plugins to gather this info and other info, I can at least tell you how I did it...

 

$_SESSION['uid'] is what session variable stores the currently logged in User ID and you can then use that to get almost any info about the client whenever a variable is not available, ie...

 

if ($_SESSION['loggedinstatus']=="true") {

 $client_info = mysql_fetch_all("SELECT firstname, lastname, companyname FROM tblclients WHERE userid = ".$_SESSION['uid']);

 if (count($client_info)) {
   $firstname = $info[0]['firstname'];
   $lastname = $info[0]['lastname '];
   $companyname= $info[0]['companyname'];
 }
}

 

If you are doing this inside the WHMCS systm, the DB connection should have already been opened by the WHMCS headers and code, so all you need to do is request the info.

 

Hope that helps!

 

Thanks, i was just double checking with matt so i didnt have to add another db hit if it wasnt needed. i like to keep them to a minimum

Link to comment
Share on other sites

  • 17 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated