FacetWP – index a post author’s team_color (usermeta)

<?php

function fwp_index_team_color( $params, $class ) {
    if ( 'team_color' == $params['facet_name'] ) {
        $post_id = (int) $params['post_id'];
        $post = get_post( $post_id ); // grab the post to find its post_author
        $color = get_field( 'team_color', 'user_' . $post->post_author ); // ACF "team_color" usermeta field
        $params['facet_value'] = $color;
        $params['facet_display_value'] = $color;
    }
    return $params;
}
add_filter( 'facetwp_index_row', 'fwp_index_team_color', 10, 2 );