Embedding Plutio messenger / chat widget onto your Wordpress website may require the following steps to fully work:
Log in to your WordPress admin.
Install the Code Snippets plugin.
After installing and activating, inside the WordPress dashboard navigate to Snippets > Add New.
Enter the title and paste the code below.
if (is_user_logged_in()) { add_action('wp_head', 'add_plutio_chat_widget'); add_action('admin_head', 'add_plutio_chat_widget'); } function add_plutio_chat_widget() { $plutioChatID = 'Add chat ID here'; $user_info = get_userdata(get_current_user_id()); $userID = 'user' . $user_info->ID; if ($user_info->first_name != '' ) { $userFirstName = $user_info->first_name; } else { $userFirstName = 'Client'; } $userEmail = $user_info->user_email; ?><script> (function (p, l, u, t, i, o) { p[t] = p[t] || function () { (p[t].q = p[t].q || []).push(arguments); }; o = l.getElementsByTagName('head')[0]; i = l.createElement('script'); i.async = 1; i.src = u; o.appendChild(i); })(window, document, 'https://cdn.plutio.com/messenger/main.js', '$plutio_msg'); $plutio_msg('<?php echo $plutioChatID; ?>', { user: { uniqueUserId: '<?php echo $userID; ?>', firstName: '<?php echo $userFirstName; ?>', contactEmails: [{ address: '<?php echo $userEmail; ?>', type: 'email' }] } }); </script><?php }
Change the value of $plutioChatID variable on line 7 to your chat widget ID. For example, the final line of code should look like this:
$plutioChatID = 'jyHa3cI4fTLQV74p';
Choose where you want to show your chat widget. I wanted to show it only in the WordPress back-end, so I chose "Only run in administration area".
Click on the "Save Changes and Activate" button.