Filter BuddyPress Multi select value to add extra markup
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
/** | |
* 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