Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Created February 25, 2020 05:01
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save zackkatz/7a70ff61c7ff7c67adebc01fd3fc1a9d to your computer and use it in GitHub Desktop.
GravityView - Display checkbox values as comma-separated instead of a bullet list
<?php
/**
* Convert checkbox <ul> to CSV values
*
* @param string $output The current output.
* @param \GV\Template_Context The template context this is being called from.
*/
add_filter( 'gravityview/template/field/checkbox/output', function( $output, $context ) {
$value = $context->value;
// If a checkbox value is '' (empty string), this removes it. If you want empty strings, remove the line below.
$value = array_filter( $value, 'gravityview_is_not_empty_string' );
return implode( ', ', $value );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment