Last active
June 8, 2020 20:30
-
-
Save sbrajesh/086c2741380a24149771cab1b32b0404 to your computer and use it in GitHub Desktop.
Filter BuddyPress Multi select value to add extra markup
This file contains hidden or 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