0

I am trying to get user info auto populated into the chat fields so logged in users don't have to type in their information everytime they want to chat with us. I cant seem to figure out how to make the user fetch call to my zoho chat - can any one help?

Here's zoho JS API call

$zoho.salesiq.ready=function()
{
  $zoho.salesiq.visitor.name("<?php echo $current_user = wp_get_current_user(); ?>");
  $zoho.salesiq.visitor.email(); 
  $zoho.salesiq.visitor.contactnumber();
}
1

As Howdy_McGee said, you need to reference the individual data points, not the whole user object.

<?php
// Get the user object: username, email, firstname, lastname, displayname, and user ID 
$current_user = wp_get_current_user();
// Get other user meta, such as phone number
// (you'll have to check what meta_key you're using for info like this)
$current_user_meta = get_user_meta($current_user->ID);
?>
$zoho.salesiq.ready=function()
{
  $zoho.salesiq.visitor.name("<?php echo $current_user->display_name; ?>");
  $zoho.salesiq.visitor.email("<?php echo $current_user->user_email; ?>"); 
  $zoho.salesiq.visitor.contactnumber("<?php echo $current_user_meta->phone; ?>");
}
| improve this answer | |
  • Thanks a lot! it works! – Sebb Jan 31 at 18:30
  • Could you please mark this as the answer in case anyone else searches for something similar? :) – WebElaine Feb 3 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.