Format Live Merge Tag Depending on another field

Installation instructions: 1. https://gravitywiz.com/documentation/how-do-i-install-a-snippet/ 2. Update FORMID, FIELDID, and the $style_field_id variable accordingly. FIELDID should be the paragraph field.

Code

Filename: gppa-format-live-merge-tag.php

<?php
/**
 * Gravity Perks // Populate Anything // Format Live Merge Tag Depending on another field
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * Installation instructions:
 *   1. https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
 *   2. Update FORMID, FIELDID, and the $style_field_id variable accordingly. FIELDID should be the paragraph field.
 */
add_filter( 'gppa_live_merge_tag_value_FORMID_FIELDID', function( $merge_tag_match_value, $merge_tag, $form, $field_id, $entry_values ) {
	$style_field_id = 5;
	$style          = rgar( $entry_values, $style_field_id );

	if ( $style !== 'Bold First 3 Words' ) {
		return $merge_tag_match_value;
	}

	return preg_replace( '/(^\w+ \w+ \w+)/', '<strong>$1</strong>', $merge_tag_match_value );
}, 10, 5 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.