diff --git a/gravity-forms/gw-advanced-merge-tags.php b/gravity-forms/gw-advanced-merge-tags.php index 206e2887f..b8c963e25 100644 --- a/gravity-forms/gw-advanced-merge-tags.php +++ b/gravity-forms/gw-advanced-merge-tags.php @@ -506,6 +506,35 @@ public function handle_field_modifiers( $value, $input_id, $modifier, $field, $r return rgar( $value_array, $index ); } break; + case 'all_fields': + // Only to be applied for GPPA scenarios, where we may using dynamically populated entry ID data. + if ( ! is_callable( 'gp_populate_anything' ) || ! gp_populate_anything()->is_field_dynamically_populated( $field ) ) { + break; + } + + // {all_fields} merge tag support needs to get the entry IDs from the raw value. + $entries = json_decode( $raw_value, true ); + + // loop through each entry ID and get the {all_fields} output. + $output = ''; + foreach ( $entries as $entry_id ) { + $entry = GFAPI::get_entry( $entry_id ); + $form = GFAPI::get_form( $entry['form_id'] ); + + // Safety check: Ensure the entry belongs to the same form as the field. + if ( $field->{'gppa-choices-primary-property'} != $entry['form_id'] ) { + break; + } + + // Get the {all_fields} output for each entry. + $all_fields_output = GFCommon::replace_variables( '{all_fields}', $form, $entry, false, false, false ); + + $output .= $all_fields_output . '
'; + } + + // if no entries were found, return the original value. + $value = $output ? $output : $value; + break; } }