Jump to content

Recommended Posts

Hi Friends,

I have found some users that may need to add certain HTML code for many different reasons to the client area of WHMCS. This could be for tracking code, Google tag manager or a custom Live chat addon that you need to ensure their custom HTML code is added to a  certain section on the page via HTML or JS code per the instructions of what you are adding to the client area pages.

The best way to achieve this would to use a custom hook. Depending on where you need to place your HTML code on the page, you would use one of the below hooks:

  1. If you want to add HTML code to be placed in the <head> section of the page your would use the ClientAreaHeadOutput hook.
  2. If you want  to add HTML code to be placed in the <body> section of the page you would use the ClientAreaHeaderOutput  hook.
  3. If you want to add HTML code to be placed in the <footer> section of the page you would use the ClientAreaFooterOutput hook

This assumes you are already familiar with creating hooks. For further information to learn how to create hooks please review the following developers documentation:
https://developers.whmcs.com/hooks/getting-started/

Once your hook is saved under your /includes/hooks/ directory in your WHMCS installation, you can use the use your browsers developer tools to Inspect the client area pages to check that your code has be inserted where it needs to be placed or where you wanted it to be placed on the page.

Instructions: I have provided example snippets below for creating a hook for each section to add HTML code to the client area pages for the <head>, <body> or <footer> sections of the client area pages after the PHP has been rendered.

All you will need to do is insert your HTML code in between the <!-- Start insert code here -->  and <!-- End insert code here --> comments in the below examples.


ClientAreaHeadOutput Hook Example: The code you place in between the comments referenced above will add your HTML code to the <head> section of every client area page:

<?php
/**
* The code below will be added in the <head> section
* @author WHMCS Danny
*/
add_hook('ClientAreaHeadOutput', 1, function($vars) {

return <<<HTML
<!-- Start insert code here -->

<!-- End insert code here -->

HTML;
});


Source: https://developers.whmcs.com/hooks-reference/output/#clientareaheadoutput

ClientAreaHeaderOutput  Hook Example: The code you place in between the comments referenced above will add your HTML code to the <body> section of every client area page:

<?php
/**
* The code below will be added in the <body> tag section
* @author WHMCS Danny
*/

add_hook('ClientAreaHeaderOutput', 1, function($vars) {

return <<<HTML
<!-- Start insert code here -->

<!-- End insert code here -->

HTML;
});



Source: https://developers.whmcs.com/hooks-reference/output/#clientareaheaderoutput

ClientAreaFooterOutput Hook Example: The code you place in between the comments referenced above will add your HTML code to the <footer> section of every client area page:

 

<?
/**
* The code below will be added to the <footer> tag section  
* @author WHMCS Danny
*/

add_hook('ClientAreaFooterOutput', 1, function($vars) {

return <<<HTML
<!-- Start insert code here -->

<!-- End insert code here -->

HTML;
});


Source: https://developers.whmcs.com/hooks-reference/output/#clientareafooteroutput

I hope this information helps anyone who is looking on how to add HTML/JS code to your WHMCS client area, such as, a tracking code, Google tag manager or a custom Live Chat addon etc.

 

Best Regards,

-  WHMCS Danny

Share this post


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

Sign in to follow this  

  • Similar Content

    • By Lightfaro
      Hi everybody!
      I need to delete or hide some links from the sidebar into the client area, as in attachment
      As they told me from the support I must do it using hooks, but I really don't know how to start
      Any help you can give me will be welcome. 😄
      Thanks!! 

    • By katyaweb
      Hello, 
       
      I have written a custom logic using hook AfterModuleSuspend. 
      WHMCS calling this hook method when I am suspending a hosting account manually from admin area. But, its not calling while daily cron suspending a hosting account.
      Is this expected ?
       
    • By dewdropz
      Can you make a hook for a specific service terminated day? Or any module available for it? For example, I am selling business email and hosting both. But for business email, termination day needs 3 days but hosting need 1month/30 days. But for whmcs default system, only 1 day I can select.
    • By trolling
      Hi, I'm writing this post in order to know if is it possible to do an action, when loading the page, using a module or a for example ? 
      Thank you for your help.
  • 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