Forum Replies Created
-
AuthorPosts
-
June 9, 2018 at 8:58 pm in reply to: Trouble getting tribe_rest_single_event_data filter to do anything #1550136
Canton
ParticipantI solved this. The REST documentation only mentions tribe_rest_single_event_data, which is only good for modifying the output from getting the output from a single event.
I dug through the source code and discovered the tribe_rest_event_data filter, which is what modifies the output of the more general /wp-json/tribe/events/v1/events endpoint.
May I recommend that the documentation be updated to include a list of all the available filters? (Or at least more than just the single filter?)
For anyone who’s looking for a way to add the custom fields to the multi-event REST output, here’s sample code for your functions.php file. Note the commented out line that lets you discover what mysterious _ecp_custom_x meta name was assigned for each of your custom fields.
add_filter( ‘tribe_rest_event_data’, ‘api_add_custom_values_all’ );
function api_add_custom_values_all( array $event_data ) {
// $meta = get_post_meta($event_id); print_r($meta); exit; // use this to figure out custom field names e.g. _ecp_custom_2
$event_id = $event_data[‘id’];
$max_participants = get_post_meta( $event_id, ‘_ecp_custom_3’, true );
$event_data[‘max_participants’] = $max_participants;
$attendance = get_post_meta( $event_id, ‘_ecp_custom_2’, true );
$event_data[‘attendance’] = $attendance;
return $event_data;
}October 16, 2015 at 1:40 pm in reply to: Customize event list widget to show OCT 16 instead of FRI 16 #1015427Canton
ParticipantWorked great, thanks: https://www.dropbox.com/s/uj2l06uf0g5kclx/Screenshot%202015-10-16%2014.39.04.png?dl=0
Note: Your trouble ticket emailing system mangled up your search/replace code some. I figured it out anyway, but I figure you might want to know that your emailing system is unnecessarily HTML-entitying in some cases:
https://www.dropbox.com/s/6s2cjy8yhw1rgng/Screenshot%202015-10-16%2014.39.37.png?dl=0
-
AuthorPosts
