Form: Add or remove staff and managers

Goal

Configure the Add Users Gravity Form so an authenticated owner or manager can invite, edit, or remove a listing’s staff and managers from inside the app, via the Edit Staff tab bar button.


Prerequisites

  • A Gravity Form for staff management with the nine field slugs listed below.
  • That form’s ID configured under Mobile App Manager → Geodirectory → Settings → GeoDirectory: Add Users.
  • mam-chat-manager active (the form depends on the mam_invite_app_user_to_post_id and mam_get_user_post_id filter contracts).
  • The listing’s package has no_of_staff_members set to a sensible value (default fallback is 5).

Form fields

ID Title Slug populate_with_key Type
1 User First Name first-name first_name text
2 User Last Name last-name last_name text
3 User Email Address user-email user_email email
4 User Role user-role user_role select (Manager / Staff)
5 Reinvite User user-reinvite checkbox
6 Delete User Check delete-user-check checkbox
7 Delete User delete-user text (conditional on field 6)
8 Listing ID postid postid hidden
9 User ID userid userid hidden

Fields 5–7 implement the “delete” workflow. The plugin uses Gravity Forms’ conditional logic (special_handling = '61' for fields 5/6, conditional show on field 7) to keep them out of the way during ordinary “add staff” flow.


Tab bar button: a list of sub-forms

The Edit Staff button is unusual: rather than opening one form, it opens an array of forms (action: open_form_array). Each entry is a sub-form pointed at the same Gravity Form ID, pre-filled with a different staff member’s data:

  • One Add Staff Member entry, with empty user fields. Excluded fields: user-reinvite, delete-user-check, delete-user (no point reinviting a user who isn’t yet there).
  • One entry per existing staff member, pre-filled with their first/last name, email, user ID, and current role. Display name is the user’s first+last (or email when names are missing).

The “Add Staff Member” entry is only included when the listing’s accepted staff count is below the package’s no_of_staff_members cap. If the cap is hit, the user can still edit/remove existing staff, but cannot add new ones until removing someone first.


Submission processing

mam_gd_add_edit_staff::add_edit_staff($values):

  1. Verifies signed-in.
  2. Reads postid. Returns Listing ID is not valid for missing or zero values.
  3. Resolves a WordPress user:
    • If userid is set, look it up by ID.
    • Else if user-email is set, look it up by email.
    • Else, create a new WordPress user with a random user_login ('user_' . wp_generate_uuid4()) and the provided email.
    • Returns Email required if neither path resolves and no email is provided.
  4. Resolves the app-user ID via mam-main mam_get_user_post_id filter. Returns App user not found on failure.
  5. Reads user-role (lower-cased; default staff), delete-user-check, and user-reinvite flags.
  6. Delete path: when delete-user-check is ON, fires mam_update_user_invitation_to_post_id with status: revoked and returns Staff member removed.
  7. Add/edit path: calls mam-chat-manager mam_invite_app_user_to_post_id with the listing ID, app user ID, and desired role. Returns Invite could not be created on failure.
  8. Stores the role as sub_role post meta on the resulting invite record. When user-reinvite is ON, sets invite_status to pending (re-arms the invite even if the user previously declined).
  9. Updates first_name and last_name user meta from the form values (when present).
  10. Sends a geodirectory-staff-invitation push notification to the invitee with the inviter’s name and listing name in the replacements.
  11. Returns Staff member updated.

Steps to enable

1. Build the Gravity Form

Match the nine field slugs above. Add conditional logic to field 7 (Delete User) so it only shows when field 6 is ticked.

2. Wire the form ID

Mobile App Manager → Geodirectory → Settings → GeoDirectory: Add Users → pick your form. Save.

3. Configure role labels

Under Settings, set mam_manager_role_name (e.g., “Listing Manager”) and mam_staff_role_name (e.g., “Listing Staff”). These are used elsewhere in the app’s UI.

4. Verify

  • Open the app as a listing owner. The Edit Staff button should appear on the detail screen.
  • Tap it. The list view should show “Add Staff Member” plus one entry per existing staff member.
  • Add a new member. Confirm the recipient receives the geodirectory-staff-invitation notification and shows up in the listing’s chat group.
  • Edit a member’s role. Confirm the sub_role meta updates.
  • Remove a member. Confirm the invite is revoked and they no longer appear in the chat group.

Variations

  • Auto-link to an existing WP user. When the email matches an existing user, the form does so already.
  • Skip auto-creation. The plugin currently always creates a new WP user when no match is found. To require a pre-existing user, intercept wp_insert_user upstream.
  • Tighten role-change permissions. The plugin lets any submitter (with permission to open the button) change a staff member’s role. Add a manager-only check by intercepting the form before it processes — e.g., a custom mam_gravity_forms_after_form_processed_{form_id} callback at lower priority.

Verification

This article was last verified against:

  • Plugin: mam-geodirectory v2.1.5
  • Source: includes/forms/staff-manager-form.php
  • Source: includes/mam_gd_form_manager.php
  • Source: includes/mam_gd_tab_bar_buttons.phpmam_app_settings_tab_bar_button_edit_staff()

Re-verify whenever the field IDs in mam_gd_form_manager::get_fields('add-users') change, the chat-manager filter contracts (mam_invite_app_user_to_post_id, mam_update_user_invitation_to_post_id, mam_get_user_post_id) change, or the staff-cap source changes from no_of_staff_members package meta.


  • Plugin: mam-geodirectory
  • Recipe: Manage staff and managers (admin)
  • Recipe: Pricing package fields
  • Listing tab bar buttons
  • Form: Manage staff invitation
  • Integration: Chat Manager
  • GeoDirectory notification types

Metadata

Field Value
Article type Recipe (Admin)
Plugin slug mam-geodirectory
Applies to plugin version 2.1.5+
Category Building Your App
Audience WordPress admin
Estimated time 10 minutes
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!