Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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