The plugin https://www.ads-software.com/plugins/wp-user-groups/ allows associating terms(in the backend only) like rea l content term association and users can be searchable with it.
Thanks for the recommendation but sadly this defeats the purpose of users being able to update their own profile from the frontend if it only works backend.
For now I’ve made it work as follows:
/**
* Filter display.
*
* @param mixed $field_value
* @param string $field_id
*
* @return mixed
*/
public static function display_filter( $field_value, $field_id = '' ) {
if ( empty( $field_value ) ) {
return;
}
$field_value = explode(',', $field_value );
$term_ids = wp_parse_id_list( $field_value );
$tax = self::get_selected_taxonomy( $field_id );
$list = '';
foreach( $term_ids as $term_id ) {
$tid = trim($term_id);
$term = get_term( $term_id, $tax );
if ( ! $term || is_wp_error( $term ) ) {
continue;
}
$query_arg = bp_core_get_component_search_query_arg( 'members' );
$search_url = add_query_arg( array( $query_arg => urlencode( $tid ) ), bp_get_members_directory_permalink() );
$list .= sprintf( '<li><a href="%1$s">%2$s</a></li>', esc_url( $search_url ), esc_html( $term->name ) );
}
if ( $list ) {
return '<ul class="bpxcftr-multi-taxonomy-terms-list">'.$list.'</ul>';
}
return '';
}
It partially works even when passing the id as the search term. It returns correct results but alos results for anywhere else that number appears e.g. phone numbers.