-
-
Save anonymous/e5d25b9b455227296eca453e500fd24c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value ) { | |
if ( $field->type == 'list' && $merge_tag != 'all_fields' && is_numeric( $modifier ) ) { | |
// count the actual number of columns | |
$choices = $field->choices; | |
$column_count = count( $choices ); | |
if ( $column_count > 1 ) { | |
// subtract 1 from column number as the choices array is zero based | |
$column_num = $modifier - 1; | |
// get the column label so we can use that as the key to the multi-column values | |
$column = rgars( $choices, "{$column_num}/text" ); | |
// get the list fields values from the $entry | |
$values = unserialize( $raw_value ); | |
$column_values = array(); | |
foreach ( $values as $value ) { | |
$column_values[] = rgar( $value, $column ); | |
} | |
$value = GFCommon::implode_non_blank( ', ', $column_values ); | |
} | |
} | |
return $value; | |
}, 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment