What it does
mam-chat-manager adds in-app chat to a MAM Suite mobile app. It provides one-on-one user-to-user chat, multi-participant group chat tied to a piece of content (a listing, a product, an order), and a built-in “support chat” channel that connects end users to a configurable group of WordPress administrators.
The plugin is server-side only — it stores threads and messages, exposes the API the mobile client calls, and dispatches push notifications when a message lands. The chat UI itself lives in the mobile app and is configured (colors, behavior, copy) from the role-aware MAM settings panel.
For developers, the plugin’s most useful extension points are a handful of filters that let other plugins decorate listing/product detail payloads with a chat button, override how a participant’s name and avatar are resolved, or post server-generated messages into a thread on the user’s behalf.
Where it appears in the app
When mam-chat-manager is active and the user is signed in, three surfaces are populated:
- Chat tab bar button. The plugin contributes a
Chaticon to the mobile app’s tab bar via the mam_main_add_tab_bar_item_chat slot. The app uses it to open the standard chat screen (the user’s thread list). - Chat block on a detail screen. When another plugin’s detail payload runs through Hook: mam_add_chat_to_detail, the response gains
has_chat,conversation_id,user_chat_name, andchat_with_avatar. The mobile client uses those to render a “Message” button on the detail screen and to open the right thread when tapped. - Admin support chat. Two content classes —
mam_admin_chat(one-on-one or group chat to admins) andmam_standard_chat(the user’s full thread list) — are registered as nav-button content types. App authors place them in the home screen, left menu, or any other navigation slot that accepts content classes.
The unread badge on each surface is driven by the messages_unread value the plugin writes into the mobile JSON on every phone-data request.
Requirements
- WordPress 6.3+
- PHP 8.1+
- MAM Suite with
mam-main1.9.1+ activated - MAM Suite plugin entitlement for
mam-chat-manager
The plugin checks both the entitlement filter and the mam-main version on admin_init. If mam-main is older than 1.9.1, an admin-side debug alert is logged and the plugin still loads — but features that depend on newer mam-main APIs (push dispatch, app-user resolution) may behave inconsistently.
Data model
mam-chat-manager stores all conversational state in three custom post types. These are private CPTs — they don’t appear in the WP admin post lists and aren’t intended to be edited directly.
| CPT | Role |
|---|---|
mam-chat-thread |
A single conversation. Each thread carries a mam_thread_key MD5 lookup hash plus the list of participants and groups that define it. |
mam-chat-message |
A single message. Always a child post of its thread (post_parent = thread ID). The author of a message is stored as the app_user post ID, not the WordPress user ID. |
mam-chat-group |
A named participant set tied to a context post (e.g. “the staff for listing 432”). Membership lives in app_user_invite records and is resolved at query time via mam_get_group_members_for_post_id. |
A few details that often come up:
- app_user vs WP user. Threads, messages, blocks, and group membership all reference the app_user post ID (from
mam-main‘sapp_userCPT), not the WordPress user. The plugin’s endpoints convert between the two ID spaces automatically; integrators using the action hooks pass WP user IDs and the plugin resolves them. conversation_idtoken. A conversation is identified to the mobile client by an opaque token that looks likemam:eyJ2IjoyLC.... It is a URL-safe base64-encoded JSON object with the participating users, groups, and context post ID. Tokens are deterministic — the same inputs always produce the same token — and stable across deployments. The token format is part of the frozen mobile contract; do not regenerate it manually.- Read state and hide-through. Per-participant read pointers (
mam_thread_last_read_{app_user_id}) and per-participant hide-through pointers (mam_thread_hidden_through_{app_user_id}) live on the thread itself, so a single thread can show different states to different participants without duplicating storage.
Mobile JSON contract
mam-chat-manager writes into the mobile JSON payload via the mam_get_phone_data_before_send pipeline. The keys it sets are part of the frozen mobile contract — renaming them will break deployed apps.
| Key | Shape | Notes |
|---|---|---|
has_chat |
'yes' |
Tells the mobile client the chat surfaces are available. |
ajaxurl |
string | Endpoint base for chat API requests. |
msg_nonce |
string | main_chat nonce sent with every chat request. |
messages_unread |
string (numeric) | Total unread messages across all threads the current user participates in. |
messages |
string (numeric) | Number of threads the current user participates in. |
On a per-detail response (a listing, a product, an order detail), Hook: mam_add_chat_to_detail additionally writes conversation_id, user_chat_name, chat_with_avatar, and the legacy chatRecipient field.
Admin pages
| Page | Slug | What it does |
|---|---|---|
| Mobile App Manager → Chat Settings | mam-cm-chat-settings |
Set the admin display name and avatar for support chat, pick which administrators are members of the support chat group. |
| Mobile App Manager → Chat History | mam-cm-chat-history |
A read-only WP_List_Table of every thread on the site, with participants and last-message preview. |
Both pages require the activate_plugins capability. The Chat Settings form uses a nonce; the older reset_chat query-parameter action is gated by manage_options plus a nonce.
The plugin also injects a Chat category into the role-aware MAM main settings panel with all of the chat appearance and behavior toggles described in Recipe: Style chat bubbles and behavior.
Hooks exposed
| Hook | Type | Audience | Purpose |
|---|---|---|---|
mam_add_chat_to_detail |
filter | PHP dev | Decorate a listing/product/order detail payload with the right conversation_id + display info. |
mam_get_thread_id_for_conversation |
filter | PHP dev | Build (and optionally create) the conversation token for a participant set. |
mam_chat_add_to_chat_thread |
action | PHP dev | Post a server-generated message into a thread on a user’s behalf. |
mam_chat_set_chat_user_name |
filter | PHP dev | Override how a participant’s display name is resolved. |
mam_chat_manager_get_user_avatar |
filter | PHP dev | Override how a participant’s avatar URL is resolved. |
mam_admin_chat_groups |
filter | PHP dev | Override the admin-chat group list when building the support thread. |
mam_admin_chat_main_post_id |
filter | PHP dev | Pin the support thread to a specific context post. |
mam_admin_chat_main_user |
filter | PHP dev | Override the user-side participant list of a support thread. |
The hooks documented in this codex cover the five most commonly used. The three mam_admin_chat_* filters are referenced inline in Recipe: Configure the admin support chat but do not have dedicated articles — they share a single use case (admin-chat customization) and are easier to discuss together than separately.
Common tasks
- Turn chat on for an app and confirm the tab bar button appears → Recipe: Enable chat
- Style the message bubbles, avatar color, and message-input area → Recipe: Style chat bubbles and behavior
- Pick the admins who answer support chat and set their display name → Recipe: Configure the admin support chat
- Add a “Message” button to a listing or product detail screen → Hook: mam_add_chat_to_detail
- Send an automated message into an existing thread (e.g. a quote, an order update) → Hook: mam_chat_add_to_chat_thread
- Override how a chat participant’s name is rendered → Hook: mam_chat_set_chat_user_name
- Override how a chat participant’s avatar is resolved → Hook: mam_chat_manager_get_user_avatar
Verification
This article was last verified against:
- Plugin:
mam-chat-managerv2.0.0 mam-main(required, ≥ 1.9.1)- Source:
mam-chat-manager.php,includes/mam_chat_manager_end_points.php,includes/mam_chat_manager_phone_data.php,includes/mam_chat_manager_admin_settings.php,content-classes/content-class-admin-chat.php
Re-verify whenever a hook is added or removed, the conversation token format changes, the CPT names (mam-chat-thread, mam-chat-message, mam-chat-group) change, the admin pages move out of local_app_setup, or the mobile JSON keys named under Mobile JSON contract change.
Related articles
- Recipe: Enable chat
- Recipe: Style chat bubbles and behavior
- Recipe: Configure the admin support chat
- Hook: mam_add_chat_to_detail
- Hook: mam_chat_add_to_chat_thread
- Hook: mam_chat_set_chat_user_name
- Hook: mam_chat_manager_get_user_avatar
Metadata
| Field | Value |
|---|---|
| Article type | Plugin Overview |
| Plugin slug | mam-chat-manager |
| Applies to plugin version | 2.0.0+ |
| Category | Plugin Reference |
| Depends on | MAM Main |
| Hooks exposed | mam_add_chat_to_detail, mam_get_thread_id_for_conversation, mam_chat_add_to_chat_thread, mam_chat_set_chat_user_name, mam_chat_manager_get_user_avatar, mam_admin_chat_groups, mam_admin_chat_main_post_id, mam_admin_chat_main_user |
| Last verified | 2026-05-01 |
