WP REST API V2 Endpoints for All Event Data?

Home Forums Welcome! Pre-Sales Questions WP REST API V2 Endpoints for All Event Data?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1078274
    Michael
    Participant

    Hi,

    How to pull in the data for events via the WP REST API V2 so that all of the data related to an event can be accessed? The event date isn’t being pulled in at http://www.contradodigital.com/wp-json/wp/v2/events/ (added this via the REST API Enabler plugin), likewise for the Venue information and all other information that is contained within the standard grey box area for an event.

    Need to pull in this data for individual events and also via the ‘all events’ API URL.

    Regards,
    Michael

    #1078449
    Brian
    Keymaster

    Hi,

    Thanks for using our plugins. I can try to help out here.

    We are not supporting the REST API until the rest of the endpoints are merged into core.

    So I will try to help out, but I am limited in what I can do.

    Since all our meta fields are protected (they start with _ ) by default the REST API ignores them.

    I think this will work to unprotect the fields:

    /**
    * THe Events Calendar - Remove Protected Custom Meta for REST API
    */
    add_filter( 'is_protected_meta', function( $protected, $meta_key ) {
    if ( '_EventStartDate' == $meta_key || '_EventEndDate' == $meta_key || '_EventDuration' == $meta_key || '_EventVenueID' == $meta_key && defined( 'REST_REQUEST' )&& REST_REQUEST ) {
    $protected = false;

    }

    return $protected;

    }, 10, 2 );

    That is only a 4 of the fields, these two resources have more:

    https://theeventscalendar.com/knowledgebase/wordpress-post-meta-data/

    https://gist.github.com/jesseeproductions/c2df90a56827dae990a0

    Once you do that you can utilize it more as in this guide:

    Working With Post Meta Data Using The WordPress REST API

    This thread might help too:

    https://theeventscalendar.com/support/forums/topic/any-wp-api-customization-to-get-day-events/

    I can try to help out more, but limited in supporting this until we add it into our plugin.

    Thanks

    #1079650
    Michael
    Participant

    Thanks Brian, this should suffice for now, I’ll have a play.

    In terms of rough timelines for expecting all end points to be supported through the API? I know this is hugely reliant on the core WP team, with their focus at the minute I can’t imagine it being longer than a few months? Is that optimistic do you feel?

    I’d rather not go creating lots of customisations which are ultimately going to be overridden in a few months as support is added from Core WP team in the API and The Events Calendar team. Wondering what to do VS what to wait for until things are updated.

    Regards,
    Michael

    #1079756
    Brian
    Keymaster

    Hi,

    Unforutnaly, I do not have a timeline to give out for when we might support it.

    I would give unique names to your custom solution so that it will continue to work even once it is in Core and we add our own support for it.

    #1086256
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘WP REST API V2 Endpoints for All Event Data?’ is closed to new replies.