Hello @adrianspk! What I think would be best is to directly filter the field output after the generic output is compiled. The “User” field type has three output value types: array, object, or ID. Looks like you’re using the default of array
. Using apply_filters( 'de/acfpoftao/format_post_title', $title, $post, $field, $post_id )
will work like this…
function de_filter_post_object_add_on_output( $title, $post ) {
$append_field = get_option( 'de_acfpoftao_append_field' );
$user = get_field( $append_field, absint( $post->ID ) );
if ( ! $user || empty( $append_field_value ) ) {
return $title;
}
$append_field_value = $user['display_name'];
$format = apply_filters( 'de/acfpoftao/append_field_data_format', get_option( 'de_acfpoftao_append_field_format' ) );
switch ( true ) {
case preg_match( "/^separator::(.*)/", $format, $matches ):
$title .= ' &' . $matches[1] . '; ' . $append_field_value;
break;
case preg_match( "/^wrap::(.*)/", $format, $matches ):
$title .= ' &l' . $matches[1] . ';' . $append_field_value . '&r' . $matches[1] . ';';
break;
default:
$title .= ' (' . $append_field_value . ')';
break;
}
return $title;
}
add_filter( 'de/acfpoftao/format_post_title', 'de_filter_post_object_add_on_output', 10, 2 );
Note: I’ve not tested this code, but in theory it should work.