Skip to main content

Add a welcome message for new users

A welcome message is a private message that lands in the new member's inbox the moment they finish registering on your site. It is the simplest onboarding hook you can ship: the recipient logs in for the first time, sees a 1 unread badge in the Better Messages widget, opens the conversation, reads the welcome from the admin or community manager, and immediately knows where to ask questions.

The snippet below registers a callback that creates a private conversation with a single recipient (the newly registered user) using Better_Messages()->functions->new_message(). Multiple add_action() lines bind the same callback to the different registration events used by BuddyPress, Ultimate Member, Paid Memberships Pro, and the standard WordPress user-registration flow — so the same snippet works on every site regardless of which membership / community plugin is active. Remove the add_action lines you don't need.

Customize the subject, content, and sender_id (the WordPress user ID who will appear as the message author) to match your site. The content field accepts HTML and respects the same sanitization rules as the rest of the messenger.

REQUIREMENTS

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 snippet will automatically send a welcome message to user which just registered at your website.

<?php

function bm_welcome_message( $user_id = false, $key = false, $user = false ){
if ( ! function_exists( 'Better_Messages' ) ) return false;

$args = array(
'sender_id' => 1, //Sender User ID
'thread_id' => false,
'recipients' => $user_id,
'subject' => 'Welcome to WordPlus.org',
'content' => "<strong>Welcome to WordPlus.org</strong>\n\n If you have any question about <strong>Better Messages</strong> you can ask it here directly.",
'date_sent' => bp_core_current_time()
);

$result = Better_Messages()->functions->new_message( $args );
}

// For BuddyPress
add_action('bp_core_activated_user', 'bm_welcome_message', 10, 3);
// For BuddyPress (if first one does not works)
add_action('bp_core_signups_after_add_backcompat', 'bm_welcome_message', 10, 1);
// For Not BuddyPress
add_action('register_new_user', 'bm_welcome_message', 10, 1);
// For Ultimate Member
add_action('um_registration_complete', 'bm_welcome_message', 10, 2);
// For Other Cases if above does not work, for example register at Paid Membership Pro Checkout
add_action('user_register', 'bm_welcome_message', 10, 2);