Advertisement
Guest User

Olark WordPress Integration

a guest
Jul 22nd, 2015
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php if (is_user_logged_in()) {
  2.     $current_user = wp_get_current_user(); ?>
  3.    
  4.     // Update the visitor's full name with their WordPress display name.
  5.     olark('api.visitor.updateFullName', {
  6.         fullName: "<?php echo htmlspecialchars($current_user->display_name, ENT_QUOTES); ?>"
  7.     });
  8.  
  9.     // Update the visitor's email address with their WordPress account email.
  10.     olark('api.visitor.updateEmailAddress', {
  11.         emailAddress: "<?php echo htmlspecialchars($current_user->user_email, ENT_QUOTES); ?>"
  12.     });
  13.    
  14.     <?php // Get the customer in Easy Digital Downloads.
  15.     if (class_exists('EDD_Customer')) {
  16.         $oCustomer = new EDD_Customer($current_user->user_email);
  17.         $nID = $oCustomer->id;
  18.         if ($nID != 0) {
  19.             $sCustomerURL = admin_url('edit.php?post_type=download&page=edd-customers&view=overview&id=' . urlencode($nID)); ?>
  20.            
  21.             // Sends the operator a link to the customer's profile page.
  22.             olark('api.chat.onBeginConversation', function () {
  23.                 // Notifies the operator - the visitor does not see this
  24.                 olark('api.chat.sendNotificationToOperator', {
  25.                     body: "Customer Page: <?php echo $sCustomerURL; ?>"
  26.                 });
  27.             });
  28.         <?php }
  29.     }
  30. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement