Integration: Chat Manager

What it does

When mam-chat-manager is active, mam-geodirectory builds chat into the listing detail screen:

  • Adds a Chat tab bar button on consumer-facing listings (with rules — see below).
  • Creates a per-listing chat group (the “listing_staff” group) lazily when needed, and registers the listing’s owner, accepted managers, and accepted staff as members.
  • Auto-enrols newly accepted staff/managers when the chat-manager fires mam_gd_staff_member_accepted, and removes them when it fires mam_gd_staff_member_removed.

Per-listing chat group

local_app_geodirectory::add_chat($listing) decides whether to attach a chat tab to a listing’s detail payload:

  1. The mam_has_chat_manager filter (owned by chat-manager) must return true.
  2. If the listing’s package meta has chat_with_venue unset or false, no chat tab.
  3. The current user and the listing’s author must not both be admins (suppress chat in admin contexts).
  4. Current user is not on the listing’s mam_staff_ user meta (owners/staff don’t chat with their own venue).
  5. Current user is not the listing’s author.

When all checks pass, the plugin calls:

mam_chat_group_manager::get_or_create_group($listing_id, 'listing_staff');

…and forwards the resulting $group_id, the current user as a participant, and the listing title/avatar to chat-manager via the mam_add_chat_to_detail filter. Chat-manager then mutates the listing payload with whatever it needs for the in-app chat tab.


Auto-enrolment of staff

The plugin subscribes to two actions fired by chat-manager (on this side these are subscribers, not producers — the actions originate elsewhere):

  • mam_gd_staff_member_accepted($listing_id, $user_id)on_staff_member_accepted(). Resolves the chat group via mam_chat_group_manager::get_or_create_group and adds the user via mam_chat_group_manager::add_member.
  • mam_gd_staff_member_removed($listing_id, $user_id)on_staff_member_removed(). Resolves the existing group via mam_chat_group_manager::get_group and removes the user via mam_chat_group_manager::remove_member.

Both handlers degrade gracefully if mam_chat_group_manager or mam_app_user_manager are not loaded.

The PLUGIN_AUDIT.md and other internal docs describe these two actions as if they were owned by mam-geodirectory. They are subscribed to here, but they are not fired anywhere in this plugin’s source. The producer is in mam-chat-manager (or wherever the staff-acceptance workflow lives). Treat them as part of chat-manager’s contract.


Admin meta box uses chat-manager filters

The Staff & Managers meta box (admin-side, see Recipe: Manage staff and managers (admin)) uses these chat-manager-owned filters:

  • mam_get_group_members_for_post_id — read accepted members per role.
  • mam_invite_app_user_to_post_id — create or update an invite record.
  • mam_reset_group_members_for_post_id_and_role — clear all members of a role before re-saving.
  • mam_get_user_post_id — map a WP user to an app-user post ID.
  • mam_get_invites_for_post_id — read pending invites.

The same filters drive the in-app Add Users form (Form: Add or remove staff and managers) and the Manage Invites form.


Steps to enable

  1. Install and activate mam-chat-manager.
  2. Confirm mam_has_chat_manager returns true for your role configuration.
  3. Configure each pricing package’s Chat With Venue checkbox — see Recipe: Pricing package fields. When unchecked, listings on that package do not show the Chat tab even when the rest of the rules pass.
  4. Verify a non-staff user opening a listing detail screen sees the Chat button (when the listing has at least one staff/manager).

Things to watch for

  • Chat group naming. The group key is hard-coded to 'listing_staff'. Two GD post types share the same listing ID space (they are different post types but share id via post_id), so listing 12 in gd_place and listing 12 in a custom CPT would share a chat group. In practice WP post IDs are global, so this isn’t an issue.
  • Owner is not implicit in the chat group. Auto-enrolment fires only when staff are added; owners must already be in the group when it is created. The add_chat() flow uses get_or_create_group so the group exists by the time it is needed, but the owner is added by the chat-manager’s own onboarding pipeline.
  • Admins on both sides. When both the viewer and the listing’s author are admins, the chat tab is suppressed entirely. This avoids exposing internal admin-to-admin chat in the consumer-facing app.

Verification

This article was last verified against:

  • Plugin: mam-geodirectory v2.1.5
  • Plugin: mam-chat-manager
  • Source: mam-geodirectory.phpon_staff_member_accepted(), on_staff_member_removed()
  • Source: content-classes/local-app-geodirectory-v2-class.phpadd_chat()
  • Source: includes/mam_gd_staff_manager.php

Re-verify whenever the chat group key ('listing_staff') changes, the chat-manager filter contracts are renamed, the package gating in add_chat() changes, or the actions mam_gd_staff_member_accepted / mam_gd_staff_member_removed are renamed by their producer.


  • Plugin: mam-geodirectory
  • Recipe: Manage staff and managers (admin)
  • Form: Add or remove staff and managers
  • Form: Manage staff invitation
  • Listing tab bar buttons
  • Recipe: Pricing package fields

Metadata

Field Value
Article type Plugin Overview
Plugin slug mam-geodirectory
Applies to plugin version 2.1.5+
Category Plugin Reference
Audience WordPress admin
Last verified 2026-05-01
Contents

    Need Support?

    Can’t find the answer you’re looking for? Don’t worry we’re here to help!