Live Merge Tags: Numbers Only Modifier

Experimental Snippet 🧪

Code

Filename: gppa-lmt-numbers-only-modifier.php

<?php
/**
 * Gravity Perks // Populate Anything // Live Merge Tags: Numbers Only Modifier
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * Experimental Snippet 🧪
 */
add_filter( 'gppa_live_merge_tag_value', function( $value, $merge_tag, $form, $field_id, $entry_values ) {
	if ( strpos( $merge_tag, ':numbersonly' ) !== false && preg_match( '/([0-9]+)/', $value, $matches ) ) {
		$value = $matches[0];
	}
	return $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.