Inject Javascript in Header Ad HTML Module

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marianoaran
    Member
    • Jun 2013
    • 39

    Inject Javascript in Header Ad HTML Module

    I'm trying to incorporate a chat tool (Zopim) in my forum so the admin can talk to users that need help.

    I'm putting this code in the "Header Ad HTML Module" and the chat tool loads correctly and works fine.

    Code:
    <script type="text/javascript">
    window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
    d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
    _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');
    $.src='//cdn.zopim.com/?XXXXXXXXXXXXXXXXXXXXXXX';z.t=+new Date;$.
    type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
    </script>
    Now, I would like the chat tool to pick up the logged in username and email address automatically. The tech people from Zopim told me to add this code to the previous:

    Code:
    <script type="text/javascript">
     
      $zopim(function() {
        $zopim.livechat.setName('Logged in name');
        $zopim.livechat.setEmail('[email protected]');
      });
     
    </script>


    Can someone help me telling me what are the variables for 'Logged in name' and '[email protected]', so it picks it up from the DB?

    Thanks!
  • Wayne Luke
    vBulletin Technical Support Lead
    • Aug 2000
    • 74132

    #2
    I don't believe those variables are exposed to the HTML and advertising modules due to security concerns.

    You can try $user['username'] and $user['email'] respectively but they are probably just empty variables as far as Javascript is concerned.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API

    Comment

    • marianoaran
      Member
      • Jun 2013
      • 39

      #3
      Thanks Luke,

      I tried this

      Code:
      $zopim.livechat.setName($user['username']);
      but it doesn't work.

      How else can I achieve this?. Is it possible to put this script in a file and call it with the header ad? If so, how would I do that?


      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...