Populate a form notification with an acf custom field

I’ve seen questions on taking form submissions and populating a ACF Field, but I want to do the opposite.

The Purpose: We want to create partner pages where a parter can send us a referral. So here is what we’ve done so far utilizing Advanced Custom Fields Pro:

  1. Created a Custom Post Type called “Partners”.
  2. Created a set of Custom Fields for the Partners CPT, one field being “Partner Number”.

So when we add a new partner we fill in the Partner custom fields and it creates a Single Partner page utilizing the info input and the Partners Single template.

Here is where it starts getting interesting…

In the Template is a Gravity Form that has the fields a partner would fill in to submit a referral. For each referral we need to know the partner number to give proper credit.

Option 1: I could have a form field for the Partner Numberadded, which they would need to manually fill out

Option 2: Have the {partner_number} field in the notification email fill in the Partner Number info dynamically based on the partner single page the form is submitted on… ABC partners referral number would be pulled in if on their page or XYZ partners number would be pulled if on their page.

Does anyone know if this is possible? Thanks if advance for any suggestions.

One common approach to something of this sort is to add a hidden field on the form and set default value with Custom Field Merge Tag to pull in a post meta from the page on which the form is embedded – {custom_field:partner_number}. Having that stored in the entry, it can then be used in the notification.

Joshua, that was way too simple. Worked like a charm. Interesting I did not need to utilize the hidden field. Simply putting {custom_field:partner_number} in the submission notification worked. I test 5 other fields the same and they worked as well.

Thank you for taking the time to help.

Ooh, nice that it works in the notification directly! I wasn’t sure whether it’d pick up from the embed post. I wonder if that works the same for both AJAX and non-AJAX embedded form. :thinking:

Deleted previous message where I test AJAx and it did not work… I copied the custom tag from this post and it had corrupted quotation marks. Corrected and resubmitted with Ajax enabled and hidden field, and it worked.

I also submitted after removing the hidden field and it worked as well.

So this works without the hidden field for ajax enabled forms and non-ajar enabled forms.

1 Like