Jump to content

Run FB messenger in WHMCS


Recommended Posts

Hello, I'm trying to include FB messenger withing WHMCS client are.  I'm using the hook written by Brian (Thanks @brian! ). However the messenger doesn't seem to be loading for some reason and i'm not able to figure it out even after trying for past 3-4 hours.. :(. I know the messenger script works just fine, it's loading successfully in my WP website, but not in WHMCS client area.. any help, highly appreciated...   (unfortunately i'm not able to use a commercial addon to achieve this, i'm trying to make this work somehow.. )

 

<?php

# Matt's Cookie Hook
# Written by brian!

function fb_chat_hook($vars) {

		return <<<HTML
		

      <noscript> <div id="fb-root"></div> </noscript>
      
	  <script type="text/javascript">
        window.fbAsyncInit = function() {
          FB.init({
            xfbml            : true,
            version          : 'v7.0'
          });
        };

        (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));</script>

 <noscript> <div class="fb-customerchat"
        attribution=setup_tool
        page_id="xxxxxxxxxxxxxxx"
  	theme_color="#67b868"
	greeting_dialog_display = "fade" >  
      </div>   </noscript>
	  
HTML;
}

add_hook("ClientAreaHeadOutput", 1, "fb_chat_hook");

 

Link to comment
Share on other sites

8 hours ago, jimsweb said:

I'm trying to include FB messenger within WHMCS client area.  I'm using the hook written by Brian (Thanks @brian! ).

in fairness, the hook was written for another purpose - you're just adapting it. 🙂

8 hours ago, jimsweb said:

However the messenger doesn't seem to be loading for some reason and i'm not able to figure it out even after trying for past 3-4 hours.. :(. I know the messenger script works just fine, it's loading successfully in my WP website, but not in WHMCS client area.. any help, highly appreciated...   (unfortunately i'm not able to use a commercial addon to achieve this, i'm trying to make this work somehow.. )

generally, I think this sort of code would go in the header or footer - so to insert this after the body tag, it would be ClientAreaHeaderOutput rather than ClientAreaHeadOutput (which is before the body tag)... try that and see if it makes any difference.

Link to comment
Share on other sites

thanks @brian!  for responding. I have tried out below code per your suggestion.  Unfortunately, it doesn't work either.  Is there a workaround that we can use to inject this messenger code to WGMSCS?   Now i'm wondering, how did the author of WHMCS messenger addon managed to inject this JS to client area...  it should be a real magic 🙂 

 

<?php

# Matt's Cookie Hook
# Written by brian!

function fb_chat_hook($vars) {

		return <<<HTML
		

      <noscript> <div id="fb-root"></div> </noscript>
      
	  <script type="text/javascript">
        window.fbAsyncInit = function() {
          FB.init({
            xfbml            : true,
            version          : 'v8.0'
          });
        };

        (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));</script>

 <noscript> <div class="fb-customerchat"
        attribution=setup_tool
        page_id="xxxxxxxxxxxxx"
  theme_color="#67b868"
  logged_in_greeting="Hello, How can we help you?"
  logged_out_greeting="Hello, How can we help you?">
      </div>   </noscript>
	  
HTML;
}

add_hook("ClientAreaHeaderOutput", 1, "fb_chat_hook");

 

Link to comment
Share on other sites

  thank you..  i just figured it out. The following code works flawlessly! I had to remove tags such as '<noscript>' and 'type="text/javascript" '  etc...  

 

<?php

# Matt's Cookie Hook
# Written by brian!

function fb_chat_hook($vars) {

		return <<<HTML
		

 <!-- Load Facebook SDK for JavaScript -->
      <div id="fb-root"></div>
      <script>
        window.fbAsyncInit = function() {
          FB.init({
            xfbml            : true,
            version          : 'v8.0'
          });
        };

        (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));</script>

      <!-- Your Chat Plugin code -->
      <div class="fb-customerchat"
        attribution=setup_tool
        page_id="xxxxxxxxxx"
  theme_color="#67b868"
  logged_in_greeting="Hello, How can we help you?"
  logged_out_greeting="Hello, How can we help you?">
      </div>
	  
HTML;
}

add_hook("ClientAreaHeaderOutput", 1, "fb_chat_hook");

 

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