gwp_get_matched_entry_value
The gwp_get_matched_entry_value modifier (or merge tag) can be used to retrieve values from entries from another form, based on a shared value. It returns one value from one matched entry: by default the newest. By default this modifier only returns entry values if you configure the access settings in Form Settings -> Advanced Merge Tags.
It works in two forms:
- As a modifier on a field merge tag: the field value is the value to match, like
{School BRIN ID:1:gwp_get_matched_entry_value form_id=2 match_id=4 return_id=1}. You can also add it to gwp_entry, gwp_user and gwp_eeid merge tags. - As a merge tag with a fixed value to match:
{gwp_get_matched_entry_value value="99ZZ" form_id=2 match_id=4 return_id=1}.
:gwp_get_matched_entry_value form_id= match_id= return_id=
{gwp_get_matched_entry_value value= form_id= match_id= return_id=}
The minimum requirements when using the Modifier are:
- form_id: ID of the Form you want to search through.
- match_id: ID of the Field within that Form you want to match the value of the Merge Tag’s field value to.
- return_id: ID of the Field that you want to get the value from.
When using it as a Merge Tag you also need to specify the value:
- value: The value you want to match with the value of the match_id field’s value. This is a fixed text; merge tags inside it are not replaced. To match a field value, use the modifier form.
Besides a numeric 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. |
Optional arguments:
- sort_by: Sort by field or entry property. Use the field-id or the entry property like ‘date_created’. (Default is ‘id’)
- sort_order: Sorts in a certain direction: asc (ascending), desc (descending) or rand (random order, to return a random matched entry). Default is ‘desc’.
- offset: Skips the number of entries specified. Default is 0 (the first entry after sorting); offset=1 returns the second.
- format: set to ‘true’ to format the matched field like a normal GF merge tag (choice labels, currency, checkbox lists, etc.). Only applies when return_id is a field ID; entry properties remain raw. Other valid options are ‘decimal_dot’ and ‘decimal_comma’ (a number with thousands separator) and ‘currency’ (in the currency of the current entry, or the default currency). Default is ‘false’: the raw stored value.
- filter1/operator1/value1 (and filter2, operator2, value2, …): extra filters on the matched entries. Supported operators: is, isnot, contains, greater_than, less_than, greater_than_or_is, less_than_or_is. valueX supports nested merge tags like *|user:ID|*.
For all operators, entry properties and sort examples, see Filter and sort matched entries. Only active entries are searched; entries in the trash or marked as spam are skipped.
Apply filters
You can also apply filters to the gwp_get_matched_entry_value Modifier and Merge Tag. This filter is executed before picking the first result (or offset), so this way you’re able to only get a matched entry value back with certain criteria.
Example of the Modifier with two filters filters:
{Text:1:gwp_get_matched_entry_value form_id="2" match_id="4" return_id="6" filter1="3" operator1="isnot" value1="Choice 1" filter2="created_by" operator2="is" value2="1"}
The same applies when you use the Merge Tag:
{gwp_get_matched_entry_value value="Something" form_id="2" match_id="4" return_id="6" filter1="3" operator1="isnot" value1="Choice 1"}
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.
Set the access in the form you read from (the form in form_id): No access (default), Logged in users, Everyone or Specify per field. With Logged in users, values are also returned in notifications and workflow steps that run later on a scheduled task (WP cron), when nobody is logged in. See Advanced Merge Tags settings for all options.
Example
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 |
|---|
Other examples
With sort_order=asc: returns the oldest entry value.
{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}
If you want to match a fixed value you can use the Merge Tag variant:
{gwp_get_matched_entry_value value="9977" form_id="2" match_id=1 return_id=2 sort_order=asc offset=1}
Frequently Asked Questions
This modifier lets you pull a single value from another Gravity Form based on a matching field. It’s perfect for showing a related name, code, or status without needing to display all entries—just the newest one that matches.
Example:
{Company ID:1:gwp_get_matched_entry_value form_id=40 match_id=4 return_id=2}
This fetches the Employee Name (field 2) from Form 40 where Company ID (field 4) matches the current form’s Company ID (field 1)
Use gwp_get_matched_entry_value when you only want one field from the newest matched entry.
Use gwp_get_matched_entries_values when you want to pull multiple fields from multiple entries.
Examples:
{Company ID:1:gwp_get_matched_entry_value form_id=40 match_id=4 return_id=2} ← one result
{Company ID:1:gwp_get_matched_entries_values form_id=40 match_id=4 return_id1=2 return_id2=3} ← multiple
You can use sort_order=asc to return the oldest matching entry. To skip results, use offset=1 to get the second match, and so on.
Example:
{Company ID:1:gwp_get_matched_entry_value form_id=40 match_id=4 return_id=2 sort_order=asc offset=1}
This fetches the second oldest Employee Name for the same Company ID.
Yes, you can apply filters just like in the plural version. Use filter1, operator1, and value1 to limit which entries are considered before selecting the top result.
Example:
{Company ID:1:gwp_get_matched_entry_value form_id=40 match_id=4 return_id=2 filter1="3" operator1="isnot" value1="archived"}
This only matches entries where Field 3 is not “archived.”
There are three main reasons: -The form or field IDs (form_id, match_id, return_id) are incorrect. -No entry matches the value you’re passing in. -You haven’t granted access to the target form’s fields. Go to the target form and check Settings > Advanced Merge Tags > Entry Access. Allow access to only the necessary fields to prevent data leaks.