Events created via Rest-API do not show up in list of upcoming events
-
I’m creating events via Rest-API for quite a while. Probably since some update of the plugin the events created via REST do no show up in the list of upcoming events anymore. Originally I did NOT set hide_from_listings in the POST-JSON. Investigating it a bit, I found out, that it does not matter what I set as hide_from_listings in the POST-JSON.
I investigated a bit further and found _EventHideFromUpcoming in the database table wp_postmeta being linked to the hide_from_listings in JSON:
1. if I omit hide_from_listings in JSON it defaults to a BLANK character in the meta_value corresponding to _EventHideFromUpcoming of this event.
2. if I put false into hide_from_listings it also results in a blank character in the database table
3. if I put true in it, it gets correctly put into _EventHideFromUpcoming (yes).
The blank setting of _EventHideFromUpcoming is then treated as true, which means that the event does not show up in upcoming events. So no matter how I set (or not set) hide_from_listings in JSON during the creation of the event via REST it will not be displayed in any upcoming events.
Further investigating into this I ended up at line 626 of src/Tribe/REST/V1/Endpoints/Single_Event.php of the plugin:
$postarr[‘EventHideFromUpcoming’] = tribe_is_truthy( $request[‘hide_from_listings’] ) ? ‘yes’ : false;
which seems to cause the trouble with setting it to the value of false. If I replace this line with:
if (tribe_is_truthy( $request[‘hide_from_listings’] )) {
$postarr[‘EventHideFromUpcoming’] = ‘yes’;
}all works as desired.
Is that a bug or do I make a mistake in the usage of the REST-API?
Thanks,
Tom
- The topic ‘Events created via Rest-API do not show up in list of upcoming events’ is closed to new replies.