Jump to content

Displaying Client Information on Client Area Pages


Recommended Posts

  • WHMCS Support Manager

The template system used by WHMCS makes it easy to add extra variables wherever extra information should be displayed. In this example I'll demonstrate how to add the Client ID to the invoice page.

This same process can be used to display any bit of available client data to almost any client area page.

 

1. Locate the template relating to the page you wish to modify. In this example I'm using viewinvoice.tpl.

Template files are located in the /templates/*your active template*/  directory.

I recommend making customisations to a custom template to ensure they are maintained following an update. More details are located here: https://developers.whmcs.com/themes/getting-started/

 

2. At the top of the file, add the following code:

{debug}

Save the file and upload it to the server.

 

3.  Visit the page in your browser, and you'll see a popup appear. This contains all the template variables and language strings available on this page.

Identify the variable you want to use, in this case it's the $clientsdetails array I need because it contains the userid:

20190708-1227.png

 

4. If the variable to use is a simple key-value pair, then it can be output simply by adding the merge field like this to the template file:

{$filename}

However in this example the client userid is contained within an array. So the format to add to viewinvoice.tpl is:

{$clientsdetails.userid}

Add the merge field into the template wherever you'd like to display the extra variables. I've added it beneath the client's name:

20190708-1234.png

 

5. Once you're happy, remove the {debug} tag, save and upload the template file.

Et Voila! The Client ID is now displayed on the invoice page:

20190708-1235.png

 

ProTip: This also works for email templates too! Sent the email to a client, then view the message via Utilities > Logs > Email Log.

For further reading, please refer to https://developers.whmcs.com/themes/variables/

 

Feel free to modify it to suit your needs and I hope it helps! 

Link to comment
Share on other sites

I think making the user number longer would benefit if you were sending the invoice off to collection company, etc if your company did that. Unless you were to keep the user ID normal, and add a custom field with some random numbers through php... Just a thought.

Link to comment
Share on other sites

29 minutes ago, mfoland said:

I think making the user number longer would benefit if you were sending the invoice off to collection company, etc if your company did that.

you could add leading zeros to it using Smarty modifiers if you wanted to.

31 minutes ago, mfoland said:

Unless you were to keep the user ID normal, and add a custom field with some random numbers through php... Just a thought.

though I would have thought a userID on an invoice is of limited use considering the value is only used internally in WHMCS.... but I know it's just an example variable. 🙂

Link to comment
Share on other sites

 
 
 
5 hours ago, WHMCS John said:

 

2. At the top of the file, add the following code:


{debug}

 

You can do so only if you are in test environment: doing so in production environment, all of your users will access to that data too... and this is a security issue.

If you want to do it in production environment, use this command:

{if $adminLoggedIn}{debug}{/if}

Credit: old trick by @brian!    😉

Link to comment
Share on other sites

  • 2 months 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