2019-11-24, 09:14 PM
If you're like me there is a lot of value to be had for having a live chat widget. But I wanted a way to get the users name without them having to have them enter it each time they wanted to chat. This tutorial will help you add this functionality to you tawk.to widget.
firstly delete your existing tawk.to widget from your mybb template.
Now open the header_welcomeblock_member template and add this code:
if you want to also provide chat support to your non-members you can also do the following:
open the header_welcomeblock_guest template and add this code:
now if the member is logged in their username will automatically be set in tawk.to otherwise you will get the standard auto-generated visitor ID that you would normally get.
IDK why it doesnt like my second code block and im sorry that this is probably in the wrong place.
firstly delete your existing tawk.to widget from your mybb template.
Now open the header_welcomeblock_member template and add this code:
<script type="text/javascript">
var Tawk_API=Tawk_API||{};
Tawk_API.visitor = {
name : '{$mybb->user['username']}',
};
var Tawk_LoadStart=new Date();
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/(enter your tawk API key here)/default';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
if you want to also provide chat support to your non-members you can also do the following:
open the header_welcomeblock_guest template and add this code:
<script type="text/javascript">
var Tawk_API=Tawk_API||{};
var Tawk_LoadStart=new Date();
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/(enter your tawk API key here)/default';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
now if the member is logged in their username will automatically be set in tawk.to otherwise you will get the standard auto-generated visitor ID that you would normally get.
IDK why it doesnt like my second code block and im sorry that this is probably in the wrong place.