Remove Spaces from Comma-delimited Values

Code

Filename: gppa-remove-spaces-from-comma-delimited-values.php

<?php
/**
 * Gravity Perks // Populate Anything // Remove Spaces from Comma-delimited Values
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 */
add_filter( 'gppa_array_value_to_text', function( $text_value, $array_value, $field ) {
	// Update "123" to your form ID and "4" to the field ID being populated.
	if ( $field->formId === 123 && $field->id === 4 ) {
		$text_value = implode( ',', $array_value );
	}
	return $text_value;
}, 11, 3 );

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.