Form: Add QR Code

Goal

Configure a Gravity Form that the app shows in its left-menu (drawer) area, with a single field that the plugin populates with the current staff member’s QR code URL. Customers scan the QR with their device camera to download the app or jump directly to the staff member’s listing.

The form is unusual: it has only one field, which is hidden in the form definition, and the plugin overwrites the field’s value (and adds aspect/can_copy_to_clipboard flags) at runtime so the app can render it as a tappable QR image.


Prerequisites

  • A Gravity Form with one hidden field with slug qrcode-field.
  • That form’s ID configured under Mobile App Manager → Geodirectory → Settings → GeoDirectory: Add QR Code to DL the App.
  • The user is a venue staff member with at least one entry in their mam_staff_locations user meta (an array of listing IDs).
  • Either:
    • branch_app_id option set, in which case the plugin generates a Branch deep link via mam_universal_link_get_branch_link and stores it in mam_site_qrcode_{listing_id} option; OR
    • mam_site_qrcode option set as a fallback site-wide QR code.

Form fields

mam_gd_form_manager::get_fields('add_qrcode_to_dl_app'):

ID Title Slug populate_with_key Type
1 QR Code Field qrcode-field qrcode hidden

add_field_features() sets special_handling = '48' on this field, which the Gravity Forms manager interprets as “render as a QR-code image preview on the app side.”


How the form is populated

mam_geodirectory_phone_data::inject_qr_code_into_form() runs on mam_get_phone_data_before_send:

  1. Reads the configured form ID (mam_geodirectory_add_qrcode_to_dl_app option) and field ID (mam_geodirectory_add_qrcode_to_dl_app_qrcode-field option).
  2. Walks data_array['left_menu'] looking for the entry with matching vc_type=form and formid={configured ID}.
  3. Within that entry’s data.fields, finds the field with the matching ID and sets:
    • value = the QR code URL (from get_qr_code_url()).
    • aspect = '1'.
    • can_copy_to_clipboard = 'yes'.
  4. If the universal-link feature is disabled (mam_universal_link_enabled filter returns false), the plugin removes the entry from the left menu entirely — i.e., the QR feature is hidden when universal links aren’t set up.

get_qr_code_url():

  • Returns mam_site_qrcode (a site-wide fallback) when the user has no mam_staff_locations.
  • For each staff location, builds (or retrieves cached) a Branch link via mam_universal_link_get_branch_link and stores it under mam_site_qrcode_{listing_id}. Currently uses $locations[0] only.
  • Falls back to an empty string if Branch is not configured.

Steps to enable

1. Build the Gravity Form

A single hidden field with the slug qrcode-field. No other fields required.

2. Wire the form ID

Settings → GeoDirectory: Add QR Code to DL the App → pick your form. Save.

3. Add the form to the left menu

In your app’s left menu / drawer configuration, add a “form” entry pointing at the same Gravity Form. The plugin will find it by formid and overwrite its single field’s value at request time.

Set branch_app_id option. The plugin’s apply_filters('mam_universal_link_get_branch_link', ...) call hands data (title, image URL, venue code) to mam-main’s universal-link feature, which returns a Branch deep link. The link is cached per listing.

5. Verify

  • Sign in as a staff member with an entry in mam_staff_locations.
  • Open the app. Open the left menu. The QR Code form entry should be there.
  • Tap the entry. The QR code image should render. Scanning it with another device should open the app to the staff member’s venue.
  • For users without mam_staff_locations, the form entry falls back to the site-wide mam_site_qrcode.

Variations

  • Suppress the form when universal links are off. This is the default behavior — turn mam_universal_link_enabled to false to hide the form. Useful when the app is in a pre-Branch state.
  • Use a different cache key. The plugin caches per listing ID (mam_site_qrcode_{listing_id}). To force a refresh, delete the option.
  • Show all locations. The plugin only uses $locations[0]. To show one QR per location, override the form data downstream — e.g., a custom mam_get_phone_data_before_send subscriber at lower priority.

Verification

This article was last verified against:

  • Plugin: mam-geodirectory v2.1.5
  • Source: includes/mam_geodirectory_phone_data.phpinject_qr_code_into_form(), get_qr_code_url()
  • Source: includes/mam_gd_form_manager.phpget_fields('add_qrcode_to_dl_app')

Re-verify whenever the form’s special-handling code (48) changes meaning in the Gravity Forms manager, the mam_universal_link_* filter contract changes, the mam_staff_locations meta key is renamed, or the cache key format (mam_site_qrcode_{listing_id}) changes.


  • Plugin: mam-geodirectory
  • Recipe: Configure the GeoDirectory settings page
  • Form: Manage staff invitation
  • Form: Add or remove staff and managers

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!