Skip to main content



WebSocket Version Guide
This functionality available only with WebSocket Version

To be able to implement this guide, you need to learn how to insert PHP snippets to your website.

You can find guide here: WP Beginner

This guide compatible with Better Messages 2.1.2 or higher


1. How to install OneSignal

  1. Download OneSignal from official website and install following standard WordPress installation process
  2. Configure OneSignal plugin following official guide

2. Configure OneSignal to assign external user id

By default, OneSignal WordPress plugin does not assign external user id to web push subscription, but that is required for sending private messages notifications, so we need configure that.

It is possible by adding this PHP snippet to your WordPress installation:

add_action('wp_footer', 'onesignal_assign_user_id', 999 );

function onesignal_assign_user_id(){
if( ! is_user_logged_in() ) return;
<script type="text/javascript">
if( typeof OneSignal !== 'undefined' ){
function updateOneSignalID(){
var uid = '<?php echo get_current_user_id() ?>';
if( uid !== user_id ){
} )

OneSignal.push(function() {

OneSignal.on('subscriptionChange', function (isSubscribed) {
if( isSubscribed ) updateOneSignalID();

After this configuration WordPress user id must be automatically assigned to OneSignal web push subscriptions when user visiting your website logged in and Better Messages should start to send web push notifications to offline users automatically.