Skip to main content

gfpdf_skip_encode_mergetags_on_fields

Description​

Gravity PDF encodes the shortcodes and merge tags in field values so they aren't processed in PDFs. You can use this filter to skip the encoding process, so the tags will be processed.

For merge tags submitted in rich text Paragraph and Post Body fields, use gfpdf_process_merge_tags_in_submitted_rich_text.

warning

Only process submitted merge tags/shortcodes on forms where you trust everyone who can submit an entry. A user can enter any merge tag or shortcode and its value will be shown in the PDF.

Version​

This filter was introduced in Gravity PDF 4.2.0.

Since Gravity PDF 6.18.0 it applies to $form_data, and an administrative field that differ from the Default Value.

Parameters​

$types | array​

  • The field types to skip. Default [ 'html', 'section' ].

$field | GF_Field​

  • The Gravity Forms field object

$entry | array​

  • The Gravity Forms entry object

$form | array​

  • The Gravity Forms form object

Usage​

Process mergetags/shortcodes in Single Line Text fields:

add_filter( 'gfpdf_skip_encode_mergetags_on_fields', function( $types ) {
$types[] = 'text';

return $types;
} );

Process mergetags/shortcodes in administrative field:

add_filter( 'gfpdf_skip_encode_mergetags_on_fields', function( $types, $field ) {
if ( ( $field->visibility ?? '' ) === 'administrative' ) {
$types[] = $field->type;
}

return $types;
}, 10, 2 );

Source Code​

This filter is located in the Helper_Abstract_Fields::encode_value_tags() method of /src/Helper/Helper_Abstract_Fields.php.