Skip to content

Instantly share code, notes, and snippets.

/file1.php Secret

Created July 31, 2017 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e5d25b9b455227296eca453e500fd24c to your computer and use it in GitHub Desktop.
Save anonymous/e5d25b9b455227296eca453e500fd24c to your computer and use it in GitHub Desktop.
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