gppa_array_value_to_text
Description
This filter allows you to modify how array/JSON values are converted into text for text-based fields such as the Single Line Text field.
Usage
add_filter( 'gppa_array_value_to_text', 'your_function_name', 10, 6 );
Parameters
$text_value string
The text which will be displayed in the text-based fields. This parameter will be unused in most cases unless you are chaining filters.
$array_value array
The array value needing to be converted to a string.
$field GF_Field
Current field.
-
The object that the template is pulling from.
$object_type GPPA_Object_Type
Current object type. Can be Post, User, Taxonomy, GF Entry, or Database.
-
The objects returned in the original query.
Examples
Use Newline As The Delimiter for Paragraph Text fields
<?php
/**
* Gravity Perks // GP Populate Anything // Use Newline As The Delimiter for Paragraph Text fields
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
add_filter( 'gppa_array_value_to_text', function( $text_value, $array_value, $field ) {
if ( $field->type !== 'textarea' ) {
return $text_value;
}
return implode( "\n", $array_value );
}, 11, 3 );
Remove Default Behavior of Using a Comma as a Delimiter
<?php
/**
* Gravity Perks // GP Populate Anything // Remove Default Behavior of Using a Comma as a Delimiter
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
add_filter( 'gppa_array_value_to_text', function( $text_value, $array_value ) {
return json_encode( $array_value );
}, 11, 2 );
Since
This filter is available since GP Populate Anything 1.0-beta-3.4.