Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sbrajesh/086c2741380a24149771cab1b32b0404 to your computer and use it in GitHub Desktop.
Filter BuddyPress Multi select value to add extra markup
/**
* Filter BuddyPress multi select value and add spans around for custom styling.
*
* @see https://buddydev.com/support/forums/topic/add-extra-css-on-a-profile-field/
*/
add_filter( 'bp_get_the_profile_field_value', function ( $value ) {
global $field;
if ( empty( $field ) || 'multiselectbox' !== $field->type ) {
return $value;
}
return join(
',',
array_map(
function ( $val ) {
return "<span class='m-select-entry'>" . $val . '</span>';
},
explode( ',', $value )
)
);
}, 9 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment