Form: Approve Listing

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 ?pid request param).
  • A configured form ID is found via mam_gf_get_form_from_cache.
  • The listing’s post_status is pending OR draft.

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):

  1. Verifies the submitter is an admin. Returns Permission denied. otherwise.
  2. Reads postid, approve value (defaults to Reject when blank), and note.
  3. Reject path: wp_delete_post($listing_id). Status string set to 'Rejected'.
  4. Approve path: wp_update_post(['ID' => $listing_id, 'post_status' => 'publish']). Status string set to 'Approved'.
  5. Composes a geodirectory-approve-listing notification message with replacements {title, note, status} for the listing’s author.
  6. Dispatches via mam_notification_send_message.
  7. 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 Approve with a note. Confirm:
    • The listing moves to publish.
    • The author receives a geodirectory-approve-listing notification with the note text.
  • Submit Reject on another listing. Confirm:
    • The post is deleted (wp_delete_post).
    • The author receives a geodirectory-approve-listing notification with status: Rejected.

Variations

  • Soft-reject instead of deleting. Replace the wp_delete_post call 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-geodirectory v2.1.5
  • Source: includes/forms/approve-listing-form.php
  • Source: includes/mam_gd_tab_bar_buttons.phpmam_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.


  • 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
Contents

    Need Support?

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