Documentation

Replace field merge tags in administrative field’s default value

Advanced Merge Tags has a feature that allows replacement of field merge tags in the for text fields that have Administrative visibility after submission of the form.

This feature can be activated in the global plugin settings:

Screenshot of the Advanced Merge Tags plugin setting screen with the 'Replace field merge tags in Administrative Text fields' toggle.

By default this works for Text fields only. The field merge tags should be added to the default value and the visibility should be administrative:

Screenshot of the Text field Advanced settings tab in the form editor screen with the default value set to '{field:1}{field:2}' and Visibility to 'Administrative'

Modify the supported field types

The gwp_amt_replace_admin_field_variables filter allows to modify the list of field types

The filter has the following parameters:

  • $field_types (array): an array of field types that should have field merge tags replaced before being saved to the database. By default, it only includes the text field type.
  • $value (string): the input value of the field.
  • $lead (array): the current entry object.
  • $field (GF_Field): the current field object.
  • $form (array): the current form object.

Developers can use this filter to add or remove field types from the $field_types array.

For example, you could add this snippet to your theme’s functions.php to add the textarea field type to the list of field types that should have field merge tags replaced before being saved to the database:

add_filter( 'gwp_amt_replace_admin_field_variables', function( $field_types, $value, $lead, $field, $form ) {
    $field_types[] = 'textarea';
    return $field_types;
}, 10, 5 );
Advanced Merge Tagsv1.6.1

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

Read more