Home › Forums › Calendar Products › Events Calendar PRO › Add Event / Import RSS programmatically with tribe_create_event
- This topic has 7 replies, 4 voices, and was last updated 9 years, 10 months ago by
samuelblackstone.
-
AuthorPosts
-
May 16, 2016 at 11:31 am #1115051
samuelblackstone
ParticipantI’m importing an RSS feed into The Events Calendar, so we can use it to display events.
Initially, if we used WP’s wp_insert_post command, we could import items as “posts”, with only partial success adding them as “events”: the imported event would get added to the database, and be marked as “published” – but was not viewable in a browser (the page would be entirely blank). Clicking “Update” would then solve both these issues.
Changing tactics, hooking into tribe_create_event is almost working: the event is added to the calendar, it is marked as published AND shows up on the site. The problem is that the event is not listed in any of the events listings. If one goes to the event and manually clicks “Update”, the event is then shown in the event listing.
The question is: what other setting needs to get triggered for the post to show up as expected once tribe_create_event is run? Debug is on, and there appear to be no conflicts. Just looking for a little clarification.
Thanks!
May 17, 2016 at 7:48 am #1115347Nico
MemberHi there @samuelblackstone,
Thanks for getting in touch with us! I’ll help you here…
I guess some metadata is not present when you save the event, and it’s generated when you manually update the event in the back-end. Can you follow-up with the code you are using to insert the event? I’ll take a look, but my guess is some metadata might be missing there.
Please let me know about it,
Best,
NicoMay 17, 2016 at 1:48 pm #1115621samuelblackstone
ParticipantI can share some code, but first let me ask about this:
I guess some metadata is not present when you save the event, and itโs generated when you manually update the event in the back-end
Are you saying that the absence of some metadata will cause the event to not update correctly? If so, that’s a surprise, since the same events do import and show as posts when imported as normal posts (and note events). The events do show date and time info as well. Is there any specific metadata that, if missing, would cause the data to not post?
I tried this two different ways: first, as a test function in our functions.php file. The second way was by using: http://feedwordpress.radgeek.com to import an RSS feed. I did a quick hack as a test and replaced their use of wp_insert_post with tribe_create_event. This got me to where I am now.
I can post the code, but it would be a lot. Let me know how you would like to proceed.
Thanks!
May 19, 2016 at 6:08 am #1116343Nico
MemberThanks for following-up!
Are you saying that the absence of some metadata will cause the event to not update correctly?
Yes, by this I mean that there’s some specific metadata to events like EventStartDate and EventEndDate that are required. You’ll need to add those parameters for the event to display, be sure to check the function docs: tribe_create_event. Are you passing those to the function?
It’s ok, maybe there’s no need to share the code if it’s super lengthy ๐
Best,
NicoMay 26, 2016 at 10:32 am #1119219samuelblackstone
ParticipantHey Nico,
Thanks for the information. This did help get me down the right path.
There were, however, a few issues with the documentation.
I didn’t see anywhere where it specifies the expected format for dates when they’re being added via EventStartDate. (note to everyone else: it appears to be PHP’s Y-m-d format).
Also, adding just the date wasn’t enough. I did have to go and specify:
EventStartHour
EventEndMinute
EventStartHour
EventEndMinuteOtherwise, I get an error when the import runs, on lines 220/221 of the API.php file where it builds these variables:
$start_date_string = "{$data['EventStartDate']} {$data['EventStartHour']}:{$data['EventStartMinute']}:00"; $end_date_string = "{$data['EventEndDate']} {$data['EventEndHour']}:{$data['EventEndMinute']}:00";The plugin: I could post the actual file, as it is open source. But there are more dependencies in its code, so that would seem perhaps more confusing than anything else.
Overall, I have items importing, but not in a totally perfect way yet (time stamps are wrong), but progress continues.
May 26, 2016 at 3:33 pm #1119453Nico
MemberWow great work digging into the code and getting this working! I wasn’t aware those were required as well thanks for pointing this out. I’ll make a note to check on this and amend the docs if necessary.
About the plugin it does sounds super useful if you polish the code and decide to publish it please let us know about it!
Please let me know if we are good to close this ticket and thanks again for bringing this up!
Best,
NicoJune 10, 2016 at 9:35 am #1125177Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Add Event / Import RSS programmatically with tribe_create_event’ is closed to new replies.
