-
Author
-
May 2, 2015 at 10:13 #57027fabienneParticipant
Hi,
I would like to use Zopim with Kleo and PMPro on my site so that when my members are logged in Zopim automatically provides me (via the Zopim live chat plugin dashboard) with the name and email of the person I am talking to.
I am lacking a bit of PHP expertise to finalise the integration and Zopim customer service has given me the following instructions which I am not sure about how to implementing.
Would anyone be able to provide the ‘missing code’?
From zopim support:
`You need to use the php functionalities of WordPress to detect if a user is logged in, prior to use the set API of Zopim.
Here’s a guide on how it works:
https://codex.wordpress.org/Function_Reference/is_user_logged_inYou will need to incorporate that with the below code:
<?php global $display_name , $user_email;
get_currentuserinfo();
echo “<script type=\”text/javascript\”>
$zopim(function() {$zopim.livechat.setName(” + $display_name +
echo ” );$zopim.livechat.setEmail(” + $user_email +
echo ” );});
</script>”;?>
‘Thanks muchly
TourismTribe.com
May 2, 2015 at 16:13 #57037sharmstrModeratorAs the link says, you use
COPY CODEif (is_user_logged_in()) { }
Just put you function inside that.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
May 3, 2015 at 00:27 #57082fabienneParticipantThanks Sharmstr,
I have tried a few options but it’s not working. Did you mean like the below?
COPY CODE/** * Zopim appears if user is logged in */ if (is_user_logged_in()) { global $display_name , $user_email; get_currentuserinfo(); echo "<script type=\"text/javascript\"> $zopim(function() { $zopim.livechat.setName(" + $display_name + echo "); $zopim.livechat.setEmail(" + $user_email + echo "); }); </script>"; }
TourismTribe.com
May 3, 2015 at 00:34 #57084sharmstrModeratorYep. That’s how you tell if a user is logged in or not. Beyond that you’ll have to ask them because I have no idea what their code does.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
May 3, 2015 at 00:35 #57085sharmstrModeratorUnless you want it to run if they are NOT logged in, then you’d change it to !is_user_logged_in(). The ! means NOT.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
May 3, 2015 at 07:38 #57094fabienneParticipantIdeally I want it to run for both (in and not logged in) but when logged in I want Zopim to give me their name and email 🙂
@sharmstr, I tried with that code in my child theme’s function PHP and the site breaks/doesnt load (big white page). I don’t know how to diagnose what I am doing wrong. Jeez I wish I was better @ php!Do I need to have anything else before the start? (apart from the <?php ?
TourismTribe.com
May 3, 2015 at 16:35 #57118sharmstrModeratorIf you copied the code from a web page, make sure you dont have fancy quote marks (left and right).
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
May 4, 2015 at 03:51 #57151fabienneParticipantThanks for poiniting that out…
Unfortunately it’s the Zopim code that breaks the site. I am waitning on their answer… I will get to the bottom of this!
TourismTribe.com
May 4, 2015 at 05:09 #57152sharmstrModeratorGood luck.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
June 2, 2015 at 11:14 #60749fabienneParticipantHi Sharmstr
Just an update and hoping I can get a little bit of more advice from you.
I still haven’t managed to finalise the Zopim integration but PMPRo has given me the code and we are very close.This is the code:
COPY CODEif (is_user_logged_in()) { global $display_name , $user_email; get_currentuserinfo(); echo "<script type=\"text/javascript\"> $zopim(function() { $zopim.livechat.setName({$display_name}); $zopim.livechat.setEmail({$user_email}); }); </script>"; }
I pasted the code (inserted it in header.php between php tags).
When logged in as demo I cannot see the info in zopim but I can see this is the backend (view source). I spent 1h on zopim support chat but we haven’t found the solution yet.I wanted to show you the below so you can assess if this is what I should be seeing? (isn’t the name missing?). Zopim was rather surprised that didn’t work as it should so I am wondering if it has something to do with Pmpro and/or kleo
I really would like to integrate Zopim with Kleo and PMPro as i feel it would be such value so I appreciate any help you can provide me.
Thanks
Thanks
below is the output in view source. I feel that something didn’t quote work on the setName as the brackets are empty
<script type=”text/javascript”>
(function() {
.livechat.setName();
.livechat.setEmail(liz@lizward.com.au);
});
</script>TourismTribe.com
June 2, 2015 at 18:50 #60779sharmstrModeratorIt clearly states in the codex that display_name doesnt work in WP 2.5+ https://codex.wordpress.org/Function_Reference/get_currentuserinfo
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
June 9, 2015 at 08:30 #61664fabienneParticipantHi,
I was meant to post an update!
It’s all sorted, the issue was I had to use the Zopim plugin and it couldn’t be done manually.
Thanks to you @sharmsr I swapped the display_name for user_ID 🙂TourismTribe.com
June 9, 2015 at 17:50 #61689sharmstrModeratorCool!
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘KLEO’ is closed to new topics and replies.