gppa_array_value_to_text

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Use Newline As The Delimiter for Paragraph Text fields
    2. Remove Default Behavior of Using a Comma as a Delimiter
  5. Since

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.

  • $object array or object

    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.

  • $objects array or object

    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.