Goal
Configure one Gravity Form per GeoDirectory post type so app users can submit new listings or edit their existing ones from the Edit Listing tab bar button. The plugin handles wiring the form to the per-post-type Add/Edit Listing slot, mapping the listing’s GD custom fields into the form’s fields, applying admin-controlled field visibility, and persisting submissions back to the GD post.
Prerequisites
- Gravity Forms installed (or whatever provides
mam_generated_forms). - A Gravity Form per GD post type that mirrors the GD custom fields you want editable from the app. The form’s IDs and field IDs are wired by slug — see Recipe: Configure the GeoDirectory settings page step 2.
gd-author-can-edit-on-appset toyesunder Settings.- The user has owner / manager / admin role for the listing being edited (or the global “user can add” gate when adding a new listing).
Field mapping
The plugin maps the listing’s GD custom fields onto the form’s fields by htmlvar_name:
| GD field type | Pre-fill behavior |
|---|---|
address |
JSON object {Street, City, State, Zip, Country}. Country defaults to United States when missing. |
business_hours |
JSON object — for each day of week sets mam-pv-start-1-delivery-day-{n}, mam-pv-end-1-delivery-day-{n}, and a dow-{n} flag. |
categories |
JSON array of subcategory names. |
tags |
(Skipped — the form definition assumes the app handles tag entry independently.) |
| Anything else | Direct copy from the listing array using $data_array[$field->htmlvar_name]. |
Fields with special_handling = '2' (set by the field-visibility manager on the admin settings page) are hidden from the app.
Form registration
Three Gravity-Forms-manager filters are subscribed to:
mam_gf_get_form_settings— appends the per-post-type form to the global form-settings list (one entry per registered GD post type, with the form’s known fields).mam_gf_get_custom_form— when the runtime asks for the form definition by ID, returns the full field set for the matching post type.mam_gf_get_custom_forms_list— appends every registered Add/Edit Listing form to the global custom forms list.
A separate listener on mam_gravity_forms_after_form_processed_{form_id} (one per registered post type’s configured form) calls save_form(). The form ID comes from mam_generated_forms keyed by post type slug.
Submission processing
mam_gd_add_edit_listing_form_handler::save_form($values):
- Verifies the user is signed in (
mam_user_id()); returns the standard not-logged-in response otherwise. - Reads the post type from the form’s first field key (e.g.,
gd_place-postid→gd_place). - Pulls
postid,post_title,post_content, and adeleteflag from the form values. - Computes
post_status:'pending'whenmam_geodirectory_add_in_draft_{post_type}is'yes','publish'for administrators,'trash'whendeleteis'Yes'.
- Creates or updates the post via
wp_insert_post/wp_update_post, then walks the GD detail table fields and saves each viageodir_save_post_meta. - Handles address, hours, categories, and image uploads.
- Returns the standard mobile-app form response (
status: success, message, etc.).
Submissions that succeed return 'refresh_return' so the app re-fetches the directory.
Steps to enable
1. Build the Gravity Form
Build a Gravity Form (or one per post type) with fields whose htmlvar_name (or admin label) matches the GD custom fields you want editable. Common fields:
post_title,post_contentaddress(single field that stores JSON)phone,email,websitebusiness_hours(single field that stores JSON)- One field per registered social platform (
facebook,instagram, etc.) featured_image(image upload)postid(hidden field; pre-filled with the listing ID when editing)delete(radio Yes/No; sendsYesto trash the listing)
2. Wire the form ID per post type
Go to Mobile App Manager → Geodirectory → GD {Post type}. Pick the Gravity Form for Add or Edit Listing Form. Save.
3. Toggle field visibility
On the same tab, scroll to the field visibility manager. Untick fields you do not want visible in the app. Save.
4. Set “Author can edit on app”
Go to Settings → Author can edit listing on app? → set to yes. Save.
5. Verify
- Open the app as a signed-in non-staff user. The Edit Listing button should NOT appear (only owner/manager/admin see it).
- Open the app as the listing’s author. The Edit Listing button should appear; tapping it opens the form pre-filled with the listing’s data.
- Submit a change. The listing’s data should refresh on save.
- For a new submission, ensure the Add Listing form is reachable via your home/menu setup (typically a button somewhere in the app config that opens the same form with
postid=0).
Variations
- Add custom fields to the form definition. Use Hook: mam_geodirectory_add_edit_form_fields to inject extra field rows into the field-visibility/registration array.
- Override post status on save. Hook into
wp_insert_post_data(WordPress core) — the plugin doesn’t expose its own filter for this. - Hide the form for a specific listing. The button is built in
mam_app_settings_tab_bar_button_edit_listing— drop the listing from the result via Hook: mam_geodirectory_skip_record, or override the tab bar via your own subscriber to themam_main_add_tab_bar_item_edit_listingfilter at a later priority.
Verification
This article was last verified against:
- Plugin:
mam-geodirectoryv2.1.5 - Source:
includes/forms/gd-add-edit-listing-manager.php - Source:
includes/mam_gd_form_manager.php - Source:
includes/mam_gd_tab_bar_buttons.php—mam_app_settings_tab_bar_button_edit_listing()
Re-verify whenever the field-mapping logic in the Edit Listing tab bar button changes (notably the special handling for address, business_hours, categories, tags), the post-status logic in save_form() changes, or the form registration walks a different option key for the form ID.
Related articles
- Plugin: mam-geodirectory
- Recipe: Configure the GeoDirectory settings page
- Listing tab bar buttons
- Hook: mam_geodirectory_add_edit_form_fields
- Form: Approve Listing
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 | 20 minutes |
| Last verified | 2026-05-01 |
