Jump to content

Show custom field WHMS 7


Recommended Posts

Use ClientAreaPage action hook.

If you are talking about Client Custom Fields you don't even need to query the database since these fields are always available when the client is loggedin.

{$clientsdetails.customfields.2.value}

Replace 2 with the Client Custom Field ID you are looking for.

Alternatively create a php file in includes/hooks directory. You should rename somePrefix_ with something else to avoid function name collision. Copy the following code in the newly created file.

use WHMCS\Database\Capsule;

function somePrefix_ClientAreaPage($vars)
{
	$clientCustomField = '2'; // Replace with the ID of your Client Custom Field

	$output['yourvariable'] = $vars['clientsdetails']['customfields'][$clientCustomField]['value'];

	return $output;
}

add_hook('ClientAreaPage', 1, 'somePrefix_ClientAreaPage');

$clientCustomField must be equal to the ID of the field that you are looking for. Now the value of your custom field is available in all pages of WHMCS and can be accessed in Smarty via {$yourvariable}. Of course you can rename it as you prefer by changing $output['yourvariable'] with $output['myawesomevariable']. With this approach the only difference is that you can freely define a name for your variable.

If you wanted to show the value of a Product Custom Fields then ignore my answer. You'll need another action hook with a query to database.

Link to comment
Share on other sites

In addition to what @Kian says, because you mention the client homepage, you could specifically use the ClientAreaPageHome hook rather than ClientAreaPage... but more than likely, you're thinking of outputting this either in a homepage panel or in an existing sidebar - each of which would require a different hook... basically, where/how you want to output this value will determine which hook to use. :smile2:

Link to comment
Share on other sites

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