This topic has 12 replies, 2 voices, and was last updated 9 years by sharmstr.

  • Author
  • #57027
     fabienne
    Participant

    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_in

    You 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

    #57037
     sharmstr
    Moderator

    As the link says, you use

    COPY CODE
    
    if (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 solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #57082
     fabienne
    Participant

    Thanks 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

    #57084
     sharmstr
    Moderator

    Yep. 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 solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #57085
     sharmstr
    Moderator

    Unless 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 solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #57094
     fabienne
    Participant

    Ideally 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

    #57118
     sharmstr
    Moderator

    If 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 solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #57151
     fabienne
    Participant

    Thanks 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

    #57152
     sharmstr
    Moderator

    Good luck.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #60749
     fabienne
    Participant

    Hi 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 CODE
    if (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

    #60779
     sharmstr
    Moderator

    It 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 solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #61664
     fabienne
    Participant

    Hi,
    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

    #61689
     sharmstr
    Moderator

    Cool!

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 13 posts - 1 through 13 (of 13 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?