Jump to content
WHMCS John

Displaying Client Information on Client Area Pages

Recommended Posts

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! 

Share this post


Link to post
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.

Share this post


Link to post
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. 🙂

Share this post


Link to post
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!    😉

Share this post


Link to post
Share on other sites

Hi,

 

Is it possible to display the dedicated IP on the invoice section?

Share this post


Link to post
Share on other sites
On 01/10/2019 at 09:56, zarvis said:

Is it possible to display the dedicated IP on the invoice section?

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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