Hi,
I need to add custom fields added with ECP to the rest event (wp-json/tribe/events/v1/events/) endpoint.
I can add these manually to the Post_Repository.php e.g.
‘price2’ => isset( $meta[‘_ecp_custom_3’] ) ? $meta[‘_ecp_custom_3’] : ”,
but to add with the ‘tribe_rest_event_data’ is difficult – there is no documentation/example that I can find.
So far I have:
add_filter( 'tribe_rest_event_data', 'sp_add_event_price' );
function sp_add_event_price( $data, $event ) {
$meta = get_post_custom( $event_id );
$data = array_merge( $data, array(
'price3' => isset( $meta['_ecp_custom_3'] ) ? $meta['_ecp_custom_3'] : '',
));
return $data;
}
Which only adds an empty string to the response.
e.g.
"price3": ""
Any help with this would be appreciated.