Hook: mam_gf_get_form_settings_fields_contact_form

About the name. The gf_ prefix predates the introduction of the built-in form handler. The filter applied only to Gravity Forms when it was introduced. As of MAM Suite 2.0, the filter applies to both the default path and the Gravity Forms path. The name is preserved for backward compatibility — do not look for a mam_default_* equivalent; this is the one filter for both paths.


Signature

apply_filters( 'mam_gf_get_form_settings_fields_contact_form', array $fields );
Parameter Type Description
$fields array Array of field definition arrays. Each entry has id, title, slug, populate_with_key, and type.

Returns: array — the modified $fields array. You must return it.


Purpose

Adds custom fields to the contact form’s logical field list. The effect depends on which setup path you’re using:

  • Default path: Fields added through this filter are rendered on the form, included in submissions, and included in the admin notification.
  • Gravity Forms path: Fields added through this filter appear in the Mobile App Manager Contact Form → Field Settings screen as mappable slugs, and are included in the admin notification once mapped. You must still add the underlying field in the Gravity Forms editor for it to render on the mobile form.

In both cases, the filter is the right tool when you want fields defined in code, shipped as part of a plugin, and version-controlled alongside the rest of your customization.


When it runs

Inside mam_contact_form_manager::mam_gf_get_form_settings() (mam-contact-form.php), in this order:

  1. The default field list is built by get_fields().
  2. Each default field’s GF field ID is written to mam-contact-formcontact_form_{slug} as a side effect.
  3. mam_gf_get_form_settings_fields_contact_form runs. ← your callback
  4. The full settings entry is appended to the GF settings registry.

The filter also runs from mam_notification_list() and process_contact_form() via the same mam_gf_get_form_settings() method (with $return_fields = true). That means it fires on every notification list build and every form submission, not just on form render.


Field shape

[
    'id'                => 7,
    'title'             => 'Street',
    'slug'              => 'street',
    'populate_with_key' => 'street',
    'type'              => 'text',
]
Key Required Notes
id yes Numeric. Use a value past the highest default ID (the defaults occupy 1–6).
title yes Display label.
slug yes Stable identifier; used as the value key on submission and the replacement key in notifications.
populate_with_key yes Mirrors slug. The Gravity Forms bridge uses this for value pre-fill.
type yes One of text, email, phone, textarea. Drives the mobile keyboard.

Default fields

Before this filter runs, $fields already contains:

[
    [ 'id' => 1, 'title' => 'Name',           'slug' => 'name',        'populate_with_key' => 'name',        'type' => 'text'     ],
    [ 'id' => 2, 'title' => 'Email',          'slug' => 'email',       'populate_with_key' => 'email',       'type' => 'email'    ],
    [ 'id' => 3, 'title' => 'Phone',          'slug' => 'phone',       'populate_with_key' => 'phone',       'type' => 'phone'    ],
    [ 'id' => 4, 'title' => 'Contact Reason', 'slug' => 'reason',      'populate_with_key' => 'reason',      'type' => 'text'     ],
    [ 'id' => 5, 'title' => 'Subject',        'slug' => 'subject',     'populate_with_key' => 'subject',     'type' => 'text'     ],
    [ 'id' => 6, 'title' => 'Description',    'slug' => 'description', 'populate_with_key' => 'description', 'type' => 'textarea' ],
]

Append to this array; do not replace it. Removing default fields will break the form on both paths.


Example: adding address fields

add_filter( 'mam_gf_get_form_settings_fields_contact_form', 'my_contact_form_fields' );

function my_contact_form_fields( $fields ) {
    $fields[] = [ 'id' => 7,  'title' => 'Street', 'slug' => 'street', 'populate_with_key' => 'street', 'type' => 'text' ];
    $fields[] = [ 'id' => 8,  'title' => 'City',   'slug' => 'city',   'populate_with_key' => 'city',   'type' => 'text' ];
    $fields[] = [ 'id' => 9,  'title' => 'State',  'slug' => 'state',  'populate_with_key' => 'state',  'type' => 'text' ];
    $fields[] = [ 'id' => 10, 'title' => 'ZIP',    'slug' => 'zip',    'populate_with_key' => 'zip',    'type' => 'text' ];
    return $fields;
}

After using this filter

On the default path: The new fields appear on the form automatically the next time the app loads it. No further admin action is required. To pre-fill them with values, see Hook: mam_contact_form_populate_contact.

On the Gravity Forms path:

  1. In Gravity Forms, add the corresponding fields to your contact form (Street, City, State, ZIP in the example above).
  2. Go to Mobile App Manager → Contact Form → Field Settings. The new field slugs will appear in the mapping dropdowns.
  3. Map each Gravity Forms field to its matching slug.
  4. Submit a test entry and confirm the new fields appear in the admin notification.

Gotchas

  • The slug is the contract. The slug value is what mam-contact-form uses internally to identify fields and what shows up as the replacement key in notifications. Once you ship a slug, do not rename it — existing data and (on the GF path) existing mappings will break.
  • Slugs must be unique. If you reuse a slug already used by a default field, the default field’s behavior will be overwritten — including auto-population for name, email, phone.
  • Always return the array. Forgetting return $fields; strips all default fields silently.
  • Filter runs on every form load, every notification list rebuild, and every submission. Keep the callback fast. Do not call external APIs or run database queries inside it. Cache aggressively if you must.
  • Field IDs are numeric and order-sensitive. The id must not collide with a default (1–6) and must not collide with any GF field ID on the GF path. Pick a high starting value (100+) if you’re unsure.
  • The gf_ in the name is misleading. The filter is path-agnostic. If you’re tempted to wrap your callback in a “is Gravity Forms active” check, don’t — you’ll skip your own fields on the default path.

Verification

This article was last verified against:

  • Plugin: mam-contact-form v2.1
  • Source: mam-contact-form/mam-contact-form.php (mam_gf_get_form_settings(), get_fields())

Re-verify whenever the field shape (id, title, slug, populate_with_key, type) changes, the default field list in get_fields() changes, or the filter is moved out of mam_gf_get_form_settings().


  • Plugin: mam-contact-form
  • Recipe: Setting up a contact form (default path)
  • Recipe: Setting up a contact form with Gravity Forms
  • Hook: mam_contact_form_populate_contact — pair with this filter to pre-fill the custom fields you’ve added
  • Hook: mam_contact_form_contact_processed

Metadata

Field Value
Article type Hook Reference
Plugin slug mam-contact-form
Applies to plugin version 2.1+
Category Extending MAM Suite
Hook type filter
Audience PHP developer
Applies to setup paths Default path AND Gravity Forms path
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!