Merge Tag: Add merge {tab} for tabbed space.

Adds merge tags {tab}, {space}, and {newline}.

Instructions

Code

Filename: gw-merge-tag-tab.php

<?php
/**
 * Gravity Wiz // Gravity Forms // Merge Tag: Add merge {tab} for tabbed space.
 *
 * Adds merge tags {tab}, {space}, and {newline}.
 *
 * Instructions:
 *  1. Install per https://gravitywiz.com/how-do-i-install-a-snippet/
 */
add_filter( 'gform_pre_replace_merge_tags', function( $text, $form, $lead, $url_encode, $esc_html, $nl2br, $format ) {
	if ( strpos( $text, '{tab}' ) !== false ) {
		$text = str_replace( '{tab}', ' ', $text );
	}

	if ( strpos( $text, '{space}' ) !== false ) {
		$text = str_replace( '{space}', ' ', $text );
	}

	if ( strpos( $text, '{newline}' ) !== false ) {
		$text = str_replace( '{newline}', "\n", $text );
	}
	return $text;
}, 10, 7 );

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.