Documentation

gwp_get_matched_entries_values

The gwp_get_matched_entries_values Modifier gets multiple values from active entries where the match_id property value of an entry equals the Merge Tag value ($value). Returns the values in html format. This is a very powerful modifier, but it has some risks. By default this modifier only returns entry values if you configure the access settings in Form Settings -> Advanced Merge Tags. Make sure to read the paragraph about preventing unintended data leakage.

:gwp_get_matched_entries_values form_id= match_id= wrap_tag= wrap_class= row_tag= row_class= col_tag= col_class= col_class_postfix= options= return_id1= value= value1=

Explanation of the paramaters:

  • 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. See additional possible id values below*.
  • row_separator: Textual separator between the rows (entries).
  • row_tag: HTML element which contains every returned entry (e.g. ‘tr’ or ‘div’)
  • row_class: CSS class for entry-row html element.
  • wrap_tag: HTML element containing the full row (e.g. table).
  • wrap_class: CSS class for container html element.
  • col_separator: Textual separator between the columns (entry values).
  • col_tag: HTML element which contains a single return value (e.g. ‘td’ or ‘div’)
  • col_class: CSS class for entry-column html element.
  • col_class_postfix: Possible values: ‘value’, ‘caption_firstword’ or ‘caption_lastword’. This applies a css class to the col_tag. Class will be the field value, the first word of the field label or the last word. This can be handy if you want to style the output based on the value or the field label.
  • options: comma separated string of one or more options:
    • ‘row_average’: Calculate and show the row average of numeric values.
    • ‘col_average’: Calculate and show the column average of numeric values.
    • ‘total_col_average’: Show the average of the column averages.
    • ‘filtercurrentuser’: Only print entries created by the current logged in user.
    • ‘created_by’: Shows the display name of the user who created the entry.
  • no_results: Message to show when no matching entries were found.
  • return_id1: ID of the first Field that you want to get the value from. More values can be retrieved by return_id2, return_id3, etc. Note that you must grant access to the target forms fields in the settings of this form.
  • value: Specify what text you want to display for each returned item by default. Possible values: ‘value’, ‘caption_firstword’ or ‘caption_lastword’.
  • value1: Specify what text you want to display for a specific returned item. This overrides the value parameter. Possible values: ‘value’, ‘caption_firstword’ or ‘caption_lastword’.
  • sort_order: Sorts the entries based on their creation date. This can be either asc (ascending) or desc (descending).
  • offset: skips the number of entries specified (counted from the most recent).
Output example which can be achieved with this modifier.

*Besides the field-id the following properties are also supported for match_id and return_id:

idThe entry’s ID
created_byID of the logged in user that submitted the form
date_createdThe date and time the entry was created, in the format “yyyy-mm-dd hh:mi:ss” (i.e. 2022-01-31 14:46:51)
ipClient IP of the user who submitted the form.
is_approvedGravity 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.

Form Settings – Advanced Merge Tags

Example

You want to quickly show a HTML table with values from another Gravity Form.

Form A: for organisation form_id=1

FIELD IDFIELD LABELENTRY EXAMPLE
1Organisation IDORG001
2Organisation NameTest Company

Form B: with client data form_id=2

FIELD IDFIELD LABELENTRY EXAMPLE
1Client IDC101
2Client NameJohn Doe
3Client E-mailjohndoe@test.com
4Client Organisation ID ORG001
FIELD IDFIELD LABELENTRY EXAMPLE
1Client IDC102
2Client NameGary Healy
3Client E-mailghealy@test.com
4 Client Organisation ID ORG001
FIELD IDFIELD LABELENTRY EXAMPLE
1Client IDC103
2Client NameGary Healy
3Client E-mailghealy@test.com
4 Client Organisation ID ORG001

Example Merge Tag

{Organisation ID:1:gwp_get_matched_entries_values form_id=2 match_id=4 wrap_tag=table wrap_class='clients-table' row_tag=tr col_tag=td value=caption_lastword col_class=client_col_ col_class_postfix=value options=created_by:col_average filter1=usr return_id1=2 return_id2=3}
  • The Merge Tag we us is {Organisation ID:1} in the context of Form 1 (Organisations). We want to retrieve data from Form 2 (Clients) to show a HTML table with a short overview of clients that belong to this organisation, showing the name of the client and the e-mailadress. So form_id points to the form we want to search through (in this example form_id=2).
  • We only want to show clients where the Organisation ID’s match, so match_id=4 (the field in the clients form where the Organisation ID is stored).
  • We want to wrap our results in a table and give the table the class ‘client-table’. You do that by defining the wrap_tag=table and wrap_class=’client-table’.
  • The row_tag=tr makes sure every client is being output in a seperate row (tr-tag).
  • Every value that we want to output gets a seperate column in the table, so col_tag=td.
  • In our HTML table, we want to show the Client name (Field ID 2 in Form ID 2), so we set return_id1=2. And in the second column on every row in the HTML table we want to show the e-mail address (Field ID 3 in Form ID 2), so add to the modifier return_id2=3. We can also add other columns by adding return_id3, return_id4 etc.

Last updated: 06-03-2024

Advanced Merge Tagsv1.4

To use the functionalities described in this documentation, you'll need to get the GravityWP - Advanced Merge Tags add-on.

Read more