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-manageractive (the form depends on themam_invite_app_user_to_post_idandmam_get_user_post_idfilter contracts).- The listing’s package has
no_of_staff_membersset to a sensible value (default fallback is5).
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 |
|
| 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):
- Verifies signed-in.
- Reads
postid. ReturnsListing ID is not validfor missing or zero values. - Resolves a WordPress user:
- If
useridis set, look it up by ID. - Else if
user-emailis 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 requiredif neither path resolves and no email is provided.
- If
- Resolves the app-user ID via mam-main
mam_get_user_post_idfilter. ReturnsApp user not foundon failure. - Reads
user-role(lower-cased; defaultstaff),delete-user-check, anduser-reinviteflags. - Delete path: when
delete-user-checkisON, firesmam_update_user_invitation_to_post_idwithstatus: revokedand returnsStaff member removed. - Add/edit path: calls mam-chat-manager
mam_invite_app_user_to_post_idwith the listing ID, app user ID, and desired role. ReturnsInvite could not be createdon failure. - Stores the role as
sub_rolepost meta on the resulting invite record. Whenuser-reinviteisON, setsinvite_statustopending(re-arms the invite even if the user previously declined). - Updates
first_nameandlast_nameuser meta from the form values (when present). - Sends a
geodirectory-staff-invitationpush notification to the invitee with the inviter’s name and listing name in the replacements. - 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-invitationnotification and shows up in the listing’s chat group. - Edit a member’s role. Confirm the
sub_rolemeta 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_userupstream. - 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-geodirectoryv2.1.5 - Source:
includes/forms/staff-manager-form.php - Source:
includes/mam_gd_form_manager.php - Source:
includes/mam_gd_tab_bar_buttons.php—mam_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.
Related articles
- 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 |
