Jump to content

Adding custom/tracking codeto body tags


spartanza

Recommended Posts

13 minutes ago, spartanza said:

I need to add one line of code within the body tags of the website - that is immediate. But ongoing, I would like to know how to do this easily and the best way with WHMCS so I can handle it myself in the future.

to insert code between the <body> and </body> tags, you could use a ClientAreaHeaderOutput hook - so in the hook below, it's adding some CSS styling to the page, but you could use it to add js or any other code too...

<?php

function insert_body_code_hook($vars)
{
	return <<<HTML
	
<style>.view-cart-tabs {display: none;}</style>

HTML;
};
add_hook("ClientAreaHeaderOutput",1,"insert_body_code_hook");

the only line in the hook that you should need to change is what goes between the two HTML tags in it - that's the code that will be added to the template.

I suppose in some circumstances you may need to edit the template (header.tpl) instead, but usually using a hook will be easier.

Link to comment
Share on other sites

On 22/08/2018 at 8:33 PM, spartanza said:

admins please delete

@spartanza can I please refer you to our WHMCS.Community Guidelines, specifically guideline 2.5

On 7/09/2016 at 8:55 PM, WHMCS ChrisD said:

2.5 Your posts assist other users, please do not delete content if you find an answer, please share this solution to help other users.

 
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