Need help with new filter ‘tribe_rest_event_data’

Home Forums Calendar Products Events Calendar PRO Need help with new filter ‘tribe_rest_event_data’

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1494187
    momofone
    Participant

    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.

    #1494218
    momofone
    Participant

    This reply is private.

    #1494360
    momofone
    Participant

    Hello,

    I think I have fixed this thanks.

    • This reply was modified 6 years, 1 month ago by momofone.
    #1494641
    Courtney
    Member

    Hi Jacqui

    That’s great to hear. Can I close out this thread?

    Thanks
    Courtney 🙂

    #1499238
    momofone
    Participant

    You sure can, thanks!

    #1500929
    Courtney
    Member

    Thanks Jacqui

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Need help with new filter ‘tribe_rest_event_data’’ is closed to new replies.