Summary
A trace of what happens between a user tapping Submit in the app and the server returning a result envelope plus dispatching any post-submission notifications.
End-to-end flow
User taps Submit in the app
│
▼
POST /wp-admin/admin-ajax.php?action=mam_gf_ajax_handler (subaction=submit_form)
│
▼
mam_gf_ajax_handler()
│ ├─ do_action('mam_gf_processing_form') ← no args, fired at the top
│ ├─ $_REQUEST['formdata'] = file_get_contents('php://input')
│ ▼
mam_gf_submit_app_form::submit_form( $form_id )
│ ├─ resolve form id from $_REQUEST['formid']
│ ├─ resolve user in the constructor (mam_user_id())
│ ▼
mam_gf_standard_form_handler::gf_standard_form( $form_id ) (default branch)
│ └─ pulls values via mam_gf_get_form_data → mam_form_manager_form_processor,
│ where custom field types extend via
│ apply_filters('mam_form_manager_process_field_type_{type}',
│ $field_value, $form_field_value, $field) (3 args)
▼
GF native validation runs (required, format, length)
│
▼
GF native submission (entry inserted)
│
▼
submit_form() picks ONE branch by has_filter(), in this order:
1. apply_filters('mam_form_manager_form_submitted_{form-id}',
$this_response, $values, $formdata)
2. mam_gravity_forms_after_form_processed_{form-id} present → standard handler
3. apply_filters('mam_for_gravity_forms_form_submitted_{form-id}',
$form_id, $post_id, $values) ← framework inserts the CPT first
4. apply_filters('mam_for_gravity_forms_form_result_form_{form-id}',
$form_id, $response)
│
└─ Per-form result builder shapes the envelope returned to the app
5. apply_filters('mam_for_gravity_forms_form_result', $form_id) (reads global)
6. apply_filters('mam_for_gravity_forms_form_result_v2', $form_id, $this_response)
▼
if process_normal && send_notifications:
do_action('mam_form_manager_send_notifications', $entry, $form) (2 args)
│
└─ Subscribers fire do_action('mam_notification_send_message', $msg)
→ MAM_Notification_Dispatcher routes email/SMS/push per the type registry
▼
JSON response to the app { status: success | failure, message: ..., redirect: ... }
Detailed phases
1. AJAX entry
mam_gf_ajax_handler is registered for both wp_ajax_mam_gf_ajax_handler and wp_ajax_nopriv_mam_gf_ajax_handler (some forms — registration, contact — accept anonymous submissions). It dispatches on $_REQUEST['subaction']; submit_form instantiates mam_gf_submit_app_form and calls submit_form( $_REQUEST['formid'] ).
The handler:
- Resolves the form id from
$_REQUEST['formid'] - Resolves the current user in the constructor (
mam_user_id(); anonymous users get user id 0) - Reads the submitted
formdatafromphp://input - Hands off to the form processor
2. Pre-process action
do_action( 'mam_gf_processing_form' ); // no args
Fires once per submission, at the very top of mam_gf_ajax_handler before the form id is even resolved. Sibling plugins observe here for analytics, side effects unrelated to the form data, etc.
3. Per-field processing
Values flow through mam_form_manager_form_processor::map_values_to_fields() (reached via the mam_gf_get_form_data filter, which mam_gf_standard_form_handler::gf_standard_form() calls). Standard field types (text, hidden, date, time, name, list) have built-in handlers. Custom field types extend via:
add_filter( 'mam_form_manager_process_field_type_{type}', function ( $field_value, $form_field_value, $field ) {
// your transform — return the processed $field_value
return $field_value;
}, 10, 3 );
⚠️ A custom field type also needs a build-time counterpart — see Custom field types.
4. Per-form submission hooks
$this_response = apply_filters(
'mam_for_gravity_forms_form_submitted_' . $form_id,
$form_id, $post_id, $values
);
This is a common extension point for customer-specific CPT-backed forms — the framework inserts/updates the post and stamps its meta, then calls this filter. Note the args are ( $form_id, $post_id, $values ), not the entry/form/confirmation triple. The related mam_form_manager_form_submitted_{form-id} is not an alias — it is a separate, higher-priority branch selected first by has_filter(), and it receives ( $this_response, $values, $formdata ).
5. Result envelope
submit_form() selects exactly one branch by has_filter(); the result-builder branches are mutually exclusive (elseif), not chained:
// branch 4
$this_response = apply_filters( 'mam_for_gravity_forms_form_result_form_' . $form_id, $form_id, $response );
// branch 5 (only if 1–4 absent) — reads global $tsl_gravity_form_result
apply_filters( 'mam_for_gravity_forms_form_result', $form_id );
// branch 6 (only if 1–5 absent)
$this_response = apply_filters( 'mam_for_gravity_forms_form_result_v2', $form_id, $this_response );
The result envelope shape is up to your handler — typical keys are status, process_normal, send_notifications, type, and message.
6. Notification dispatch
do_action( 'mam_form_manager_send_notifications', $entry, $form ); // 2 args
This fires from the process_normal path only when the handler’s result envelope left send_notifications truthy. It is the contract between forms-manager and notifications-manager. Subscribers fire do_action('mam_notification_send_message', $msg) for whatever needs to be emailed/SMS’d/pushed:
- Confirmation to the submitter
- Alert to the listing owner
- Admin notification for moderation queues
Don’t fire mam_notification_send_message directly from your submission handler — go through mam_form_manager_send_notifications so admin overrides can intercept.
7. JSON response
The handler returns a JSON envelope to the app. The mobile client surfaces the message and follows the optional redirect.
Verification
- A failed submission returns
status: failurewith a message - The per-form
mam_for_gravity_forms_form_submitted_{form-id}filter fires once per submission (verify with amamdebuglog) - Every notification visible in Mobile App Manager → Notifications → Outbox Viewer corresponds to a
do_action('mam_notification_send_message')triggered from amam_form_manager_send_notificationssubscriber
Related articles
- Forms manager overview
- Custom field types
- Form cache and invalidation
- Hook: mam_for_gravity_forms_form_resultform{id}
- Hook: mam_form_manager_send_notifications
- Hook: mam_notification_send_message
- Hook: mam_gravity_forms_after_formprocessed{id}
Metadata
| Field | Value |
|---|---|
| Article type | Plugin Overview |
| Plugin slug | mam-main |
| Applies to plugin version | 2.1.11+ |
| Category | Plugin Reference |
| Audience | PHP developer |
| Last verified | 2026-05-02 |
