Goal
Wire an Approve Listing Gravity Form so administrators viewing a pending or draft listing in the app can approve or reject it without leaving the app. Approval flips the listing to publish; rejection deletes the post entirely. Either way, the author is notified.
Prerequisites
- A Gravity Form for the approve flow.
- That form’s ID configured under Mobile App Manager → Geodirectory → Settings → GeoDirectory: Approve Listing.
- The current viewer is a WordPress administrator.
Form fields
mam_gd_form_manager::get_fields('approve_listing'):
| ID | Title | Slug | populate_with_key | Type |
|---|---|---|---|---|
| 1 | Approve | approve |
approve |
radio (Approve / Reject) |
| 2 | Note | note |
note |
textarea |
| 3 | Listing ID | postid |
postid |
hidden |
Field 1’s choices are populated at runtime by add_field_features().
Tab bar button
The Approve Listing button (mam_app_settings_tab_bar_button_approve_listing) appears only when:
- The viewer is an admin (per
mam_user_is('administrator', $user_id)in the role-trait check, gated by?pidrequest param). - A configured form ID is found via
mam_gf_get_form_from_cache. - The listing’s
post_statusispendingORdraft.
When all three are true, the button’s source is the form index, and the form is pre-populated with postid: {listing_id}.
Submission processing
mam_gd_approve_listing::approve_listing($values):
- Verifies the submitter is an admin. Returns
Permission denied.otherwise. - Reads
postid,approvevalue (defaults toRejectwhen blank), andnote. - Reject path:
wp_delete_post($listing_id). Status string set to'Rejected'. - Approve path:
wp_update_post(['ID' => $listing_id, 'post_status' => 'publish']). Status string set to'Approved'. - Composes a
geodirectory-approve-listingnotification message with replacements{title, note, status}for the listing’s author. - Dispatches via
mam_notification_send_message. - Returns
'Listing have been Approveed.'or'Listing have been Rejected.'. (The message string is built by concatenating the action verb with'ed.', so the wording reads as written.)
Steps to enable
1. Build the Gravity Form
Three fields with the slugs approve, note, postid. The approve field’s choices are populated by the plugin at runtime, so the choices configured in the form editor are ignored.
2. Wire the form ID
Settings → GeoDirectory: Approve Listing → pick your form. Save.
3. Verify
- Submit a listing as a regular user with Add in Draft turned on. The listing appears in
pending. - Open the app as an admin. Browse to the pending listing’s detail screen.
- Confirm the Approve Listing tab bar button appears.
- Submit
Approvewith a note. Confirm:- The listing moves to
publish. - The author receives a
geodirectory-approve-listingnotification with the note text.
- The listing moves to
- Submit
Rejecton another listing. Confirm:- The post is deleted (
wp_delete_post). - The author receives a
geodirectory-approve-listingnotification withstatus: Rejected.
- The post is deleted (
Variations
- Soft-reject instead of deleting. Replace the
wp_delete_postcall with a status change (e.g.,trash) by hooking your own Gravity Forms result handler at higher priority and returning a non-default response. - Bulk approve. Not built in. The Approve Listing flow is per-listing.
- Custom note formatting. The note is sent as-is in the replacements array. The notification template controls formatting; see GeoDirectory notification types.
Verification
This article was last verified against:
- Plugin:
mam-geodirectoryv2.1.5 - Source:
includes/forms/approve-listing-form.php - Source:
includes/mam_gd_tab_bar_buttons.php—mam_app_settings_tab_bar_button_approve_listing() - Source:
includes/mam_gd_form_manager.php
Re-verify whenever the radio choices in add_field_features('approve_listing') change, the post-status logic (pending / draft) for showing the button changes, or the rejection action moves from wp_delete_post to a status change.
Related articles
- Plugin: mam-geodirectory
- Recipe: Configure the GeoDirectory settings page
- Form: Add/Edit Listing
- Listing tab bar buttons
- 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 | 5 minutes |
| Last verified | 2026-05-01 |
