gwp_get_matched_entry_value
The gwp_get_matched_entry_value Modifier can be used to retrieve values from entries from another form, based on a shared value. By default this modifier only returns entry values if you configure the access settings in Form Settings -> Advanced Merge Tags.
:gwp_get_matched_entry_value form_id= match_id= return_id=
The minimum requirements when using this Modifier are at least:
- form_id: ID of the Form you want to search through.
- match_id: ID of the Field within that Form that matches your current Merge Tag ID.
- return_id: ID of the Field that you want to get the value from.
Besides the field-id the following properties are also supported for match_id and return_id:
id | The entry’s ID |
created_by | ID of the logged in user that submitted the form |
date_created | The date and time the entry was created, in the format “yyyy-mm-dd hh:mi:ss” (i.e. 2022-01-31 14:46:51) |
ip | Client IP of the user who submitted the form. |
is_approved | Gravity View entry approval status. The Gravity View {approval_status} documentation gives insight in possible values. E.g. 1 = Approved. |
Allowing access to other form fields
To prevent unintended data leakage access to another forms entry values by this merge tag modifier are not allowed by default (‘No access’). Before you allow access you must think about if a user / visitor is able to change the match value and therefore able to retrieve data from other entries the user / visitor might not be allowed to see. Acces can be allowed in the ‘Advanced Merge Tags’ tab in the Form Settings. Generally it is advised to only allow access to form fields which do not contain sensitive information.
Examples
A real life example. You have a Gravity Form with data about schools (in the Netherlands, schools have an unique ID, which looks like this: 99ZZ). Every school has such a unique identifier. Imagine that you have another Form on your site for Dutch teachers. They can easily fill in their unique school ID.
Based on this unique code, you want to find a match with the school and retrieve more data about the school, for example the address, telephone number or a postal code.
Let’s see how we can quickly do that with using the gwp_get_matched_entry_value Merge Tag:
Form A: for teacher form_id=1
Field ID | Field Label | Entry example |
---|---|---|
1 | School BRIN number | 99ZZ |
2 | Name Teacher | John Doe |
Form B: with School data form_id=2
Field ID | Field Label | Entry example |
---|---|---|
1 | School name | Primary School the Balloon |
2 | Address | Streetname 3, 2801SX, Gouda |
3 | Telephone | +310700000001 |
4 | School BRIN number | 99ZZ |
Use Merge Tag Modifier in Form A
After the teacher submits her Form, you send an e-mail. In the e-mail you want to show the school name that matches with the unique BRIN id. When we use the Merge Tag without modifiers, it will return the BRIN number:
{School BRIN ID:1} | 9977 |
Now we want to find the school name. We can do that by adding our Modifier like this:
{School BRIN ID:1:gwp_get_matched_entry_value form_id=2 match_id=4 return_id=1} | Primary School the Balloon |
{Textfield:1:gwp_get_matched_entry_value form_id="2" match_id='1' return_id=2 sort_order=asc}
with offset=1: returns the second oldest entry value.
{Textfield:1:gwp_get_matched_entry_value form_id="2" match_id='1' return_id=2 sort_order=asc offset=1}
Last updated: 09-03-2022