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. More than one of them fires for a single registration (user_register runs inside the front-end flow that also fires register_new_user), so the callback records a bm_welcome_sent flag on the user and returns early on later hooks. That way you can leave every line in place and still send exactly one welcome.
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.
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;
if ( ! $user_id ) return false;
// Several of the hooks below fire for the same registration, so send only once per user.
if ( get_user_meta( $user_id, 'bm_welcome_sent', true ) ) return false;
update_user_meta( $user_id, 'bm_welcome_sent', 1 );
$args = array(
'sender_id' => 1, //Sender User ID
'thread_id' => false,
'recipients' => $user_id,
'subject' => 'Welcome to our community',
'content' => "<strong>Welcome to our community</strong>\n\n If you have any question 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);