Knowledgebase

Displaying Custom Fields on Pages

In WHMCS, you can display custom fields on pages using template hooks or by directly editing the template files. Here's a step-by-step guide:

Method 1: Using Template Hooks

  1. Log into WHMCS:

    Access your WHMCS admin panel using your administrator credentials.

  2. Navigate to Template Hooks:

    • Go to "Setup" in the top menu.
    • Click on "Addon Modules."
    • Find the specific hook point where you want to display the custom field and click on it.
  3. Create a Hook Function:

    • Write a PHP function to fetch and display the custom field. For example:
    php
    function hook_display_custom_field($vars) { $customField = get_custom_field_value($vars['client_id'], 'custom_field_name'); return 'Custom Field Value: ' . $customField; }

    Replace 'custom_field_name' with the actual name of your custom field.

  4. Save the Hook:

    • Save the hook function.

Method 2: Direct Template Editing

  1. Locate the Template File:

    • Identify the template file where you want to display the custom field. For example, if you want to add it to the client area, you might be editing a file like clientarea.tpl.
  2. Edit the Template File:

    • Open the template file with a text editor.
    • Add the following code to display the custom field:
    smarty
    {php} $customField = get_custom_field_value($client_id, 'custom_field_name'); {/php} Custom Field Value: {$customField}

    Replace 'custom_field_name' with the actual name of your custom field.

  3. Save the Template File:

    • Save the edited template file.

Note:

  • Always make backups of your files before making changes to ensure you can restore them if something goes wrong.
  • Ensure that the custom field is associated with the client or in order for it to be available in the template.
  • If you're not familiar with PHP and template files, consider consulting with a developer or WHMCS expert for assistance.

Remember to test the changes thoroughly to ensure they work as expected on your WHMCS site.

  • 0 Users Found This Useful
Was this answer helpful?