Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to set Visitors name and mail from Drupal module #1

Closed
pablo-tapia opened this issue May 20, 2016 · 1 comment
Closed

Failed to set Visitors name and mail from Drupal module #1

pablo-tapia opened this issue May 20, 2016 · 1 comment

Comments

@pablo-tapia
Copy link

I'm using the module in a development site, the widget is loading nicely and it's using the remote configurations I set on my dashboard. Now I'm trying to set the name and email by default when the user access the site but so far I'm out of luck.

Here's the code I'm using:

### global `$user;

$user = user_load($user->uid);
$name = (int) $user->uid > 0 ? $user->field_first_name['und'][0]['value'] .' '. $user>field_last_name['und'][0]['value'] : $user->name;
  $email = (int) $user->uid > 0 ? $user->mail : '';

  return t('<!--Start of Tawk.to Script-->
    <script type="text/javascript">
        var Tawk_API = Tawk_API || {}, Tawk_LoadStart = new Date();
        (function(){
            var s1 = document.createElement("script"), s0 = document.getElementsByTagName("script")[0];
            s1.async = true;
            s1.src = "https://embed.tawk.to/@p/@w";
            s1.charset = "UTF-8";
            s1.setAttribute("crossorigin","*");
            s0.parentNode.insertBefore(s1,s0);
        })();

        Tawk_API.onLoad = function() {
            Tawk_API.visitor = {
                name  : \'@n\',
                email : \'@m\'
            };
            console.log("@m");
        };
    </script><!--End of Tawk.to Script-->', array('@p' => $page_id, '@w' => $widget_id, '@m' => $email, '@n' => $name));

(BTW I'm using the t function which I believe makes sense because it's cleaner code)

The events are loading correctly and the variable is set with the correct data but the widget never get's the name, it always ask me to set it manually. Am I doing something wrong here?

@pablo-tapia pablo-tapia changed the title Failed to setup Name and Mail from Drupal module Failed to set Visitors name and mail from Drupal module May 20, 2016
@GeekOfAges
Copy link

This issue has been fixed on master and visitor details are being set here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants