Skip to main content

better_messages_user_conversation

Compatibility
This guide compatible with Better Messages 2.5.2 or higher

Embed a direct conversation between the current visitor and a specified user. If they've never messaged before, the thread is created automatically. If a thread already exists, that thread is displayed. Perfect for author bio pages, vendor profiles, coach landing pages, and any context where a user should land directly in conversation with a specific person.

When to use it#

Use casePattern
Author bio "Message me" pageAuto-pull author from post context, embed DM thread
Marketplace vendor storefront"Message vendor" page with their dedicated thread
Coaching / consulting landing pageClient lands directly in conversation with the coach
Telemedicine practitioner profilePatient gets direct chat with their assigned practitioner
Support staff individual pageDirect DM with a specific support rep

Attributes#

AttributeWhat it doesDefault
user_idThe user to start/show a conversation withAuthor of the current WordPress post or page

Usage#

[better_messages_user_conversation user_id="55"]

If user_id is omitted, the post/page author is used:

[better_messages_user_conversation]

Examples#

Coaching page#

[better_messages_user_conversation user_id="12"]

Embed on a coach's landing page (user ID 12 = the coach). Visitors land directly in a private conversation with the coach.

Marketplace vendor profile#

// In a vendor profile template:
$vendor_id = get_vendor_id_from_context();
echo do_shortcode('[better_messages_user_conversation user_id="' . $vendor_id . '"]');

Each vendor profile gets a per-vendor DM thread auto-created for new visitors.

Author bio (auto-detect)#

[better_messages_user_conversation]

When placed on a post or page, no user_id needed — the post author becomes the recipient. Great for author bio boxes that consistently behave across all posts.

Frequently asked questions#

What happens if the visitor isn't logged in?#

The shortcode shows a login form first. After login, the user is taken directly to the conversation with the specified user.

Does this create a new thread every time?#

No — if a thread already exists between the two users, that thread is reused. New thread only when no prior conversation exists.

Can guests use this shortcode?#

Only with guest chat enabled. Guests get a transient identity for the conversation.

What if the specified user_id doesn't exist?#

The shortcode shows a "user not found" notice. Always validate the user_id in dynamic shortcode usage.

Is there a way to prepopulate a message?#

Not in the default UI. To pre-post a message into the thread programmatically, call Better_Messages()->functions->new_message( [ 'sender_id' => …, 'recipients' => …, 'content' => … ] ) before rendering, or use a JS filter on the input.

See also#