Title: Programatically Create and Update Events
Last modified: July 12, 2023

---

# Programatically Create and Update Events

 *  Resolved Anonymous User 13711045
 * (@anonymized-13711045)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/)
 * What is the proper way to programatically add and update events? The `tribe_create_event`
   function doesn’t work. The event is created but doesn’t show on the frontend.
   The documentation is pretty poor for this area.
    -  This topic was modified 2 years, 11 months ago by Anonymous User 13711045.

Viewing 12 replies - 16 through 27 (of 27 total)

[←](https://wordpress.org/support/topic/programatically-create-and-update-events/?output_format=md)
[1](https://wordpress.org/support/topic/programatically-create-and-update-events/?output_format=md)
2

 *  [noahkuhn](https://wordpress.org/support/users/noahkuhn/)
 * (@noahkuhn)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17246461)
 * Having a similar issue. An event is created by Gravity Forms using their “advance
   post creation” tool. The event gets created, with the correct dates etc. My workflow
   is to set it as a draft initially and then at a later date, update the status
   via an API call to “publish” the event. In my case, I can update the status easily
   using tribe_update_event. This makes the event appear “published” in the backend,
   but it won’t appear on the front end, unless I go to the post and manually click“
   Update”. There must be some step needed to actually update the post and make 
   sure that it is fully available to display on the calendar. I attempted using
   `
   tribe()->make( \TEC\Events\Custom_Tables\V1\Repository\Events::class )->update(
   $event_post_id, [] );`
 * But it doesn’t seem to make a difference. No rows are added to tec_events or 
   tec_occurences. Any help would be greatly appreciated. I see that example is 
   passing a blank array into the second argument, do I need to manually get the
   date values etc and pass those in?
    -  This reply was modified 2 years, 6 months ago by [noahkuhn](https://wordpress.org/support/users/noahkuhn/).
 *  Plugin Support [Darian](https://wordpress.org/support/users/d0153/)
 * (@d0153)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17251731)
 * Hi [@noahkuhn](https://wordpress.org/support/users/noahkuhn/)
 * Thanks for your message.
 * I think the way you created your event is different since you’re using the Gravity
   Forms.
 * Please try creating your event by following this [thread](https://wordpress.org/support/topic/programatically-create-and-update-events/#post-16892671),
   and after that, run the script you provided so that it will create the necessary
   record to tec_events and tec_occurences table, and see if that works for you.
 * Let me know if you have further questions or concerns.
 *  [noahkuhn](https://wordpress.org/support/users/noahkuhn/)
 * (@noahkuhn)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17251772)
 * Unfortunately that would totally change my workflow, not allowing me to use the
   Advanced Post Creation tool any more? Is there any more advice on how I could
   trigger an existing tribe_events post to actually be an event with rows in those
   extra fields? Again, it works when I manually click “Update” on an event that
   has had its status changed from draft to publish programatically. At that point
   I can set it back to draft and “publish” it again via the api and it works correctly.
   Really hoping there is some trigger I can call to make the post an actual “event”.
 *  Plugin Author [Sam](https://wordpress.org/support/users/sdokus/)
 * (@sdokus)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17255027)
 * Hi [@noahkuhn](https://wordpress.org/support/users/noahkuhn/) – I just wanted
   to jump in here to share that our ORM documentation has been moved here ([https://docs.theeventscalendar.com/apis/](https://docs.theeventscalendar.com/apis/))
   and I am actively working on improving it, so your feedback is super appreciated!
 * It’s also worth mentioning that we have a bug identified where the `tribe_events()-
   >save();` functionality for updating events is not currently working but there
   is an internal bug ticket **[TEC-4935]** where we are actively working to resolve
   this.
 *  [hwuser](https://wordpress.org/support/users/hwuser/)
 * (@hwuser)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17507024)
 * I also created the Event (CPT tribe_events) from a third-party application (from
   Airtable), and it did not create the related records in the “tec_events” and “
   tec_occurrences” tables… So I had the same problem as everyone, which is not 
   I didn’t see the event on the calendar nor did the single events page show me.
 * But I found the solution: When I create the event, I fill in the custom fields:
   
   _EventStartDate_EventStartDateUTC_EventEndDate_EventEndDateUTC_EventTimezone
 * And now it does create the records in the related tables!!!!
 *  Plugin Support [Darian](https://wordpress.org/support/users/d0153/)
 * (@d0153)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17511301)
 * Hi [@hwuser](https://wordpress.org/support/users/hwuser/)
 * Thank you for taking the time to provide us with your feedback. It’s great to
   hear that you were able to find a solution to the issue you were facing.
 * Your input is incredibly valuable to us, and we appreciate your effort in sharing
   your thoughts with us. I will make sure to pass along your feedback to the rest
   of the team for further review and consideration.
 *  [shingen0810](https://wordpress.org/support/users/shingen0810/)
 * (@shingen0810)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17554017)
 * Hi [@hwuser](https://wordpress.org/support/users/hwuser/),
   I am now facing a 
   similar issue as everyone and I would like to know how you solve this issue.1–
   You mentioned that “when I create the event …”. Did you fill the custom fields
   on a WP post edit page or from the third party platform (Airtable)? 2. – Also,
   you mentioned that ” it does create the records in the related tables”. Not sure
   how you run the “Airtable”, but I would like to know…2-a: Are you publishing 
   the event posts from Airtable APP to WP?2-b: Do you sent all data which TEC need
   to be stored from Airtable APP?I publish the event posts by fetching posts from
   outside (ex. Blogging site to WP) and I have the script code to store the data
   on TEC.Thank you for answering in advance.
 *  [hwuser](https://wordpress.org/support/users/hwuser/)
 * (@hwuser)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17557539)
 * Hello [@shingen0810](https://wordpress.org/support/users/shingen0810/),
 * I have used this plugin that creates posts or cpt when you create a record in
   Airtable (or in a view).
   [https://wordpress.org/plugins/air-wp-sync/](https://wordpress.org/plugins/air-wp-sync/)
 * At first, I did not create the records in the related tables, but by testing,
   by incorporating the mentioned fields, they were created.
 * That is why I have written it as an idea, for those who use the creation of events
   from third-party plugins, to try filling out these fields to see if that works
   for them.
 *  [shingen0810](https://wordpress.org/support/users/shingen0810/)
 * (@shingen0810)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17558916)
 * Hi [@hwuser](https://wordpress.org/support/users/hwuser/),
   Thank you for your
   replay.I understood your comment and I have tested on my side. It is really shame
   to say that I failed to publish the event posts by adding these meta fields from
   third party WP plugin. = We still need to press “update” on the event edit page
   to publish the event posts properly…As we can read and check this thread, we 
   need to wait for the TEC team to fix this issue. I suppose the problem occurs
   when TEC save or store the data in DB since version 6. On our side, it does work
   like a charm until version 5.8.2 .I guess there is nothing that we can do at 
   this moment, but we are considering to connect Gravity form to TEC for publishing
   the event for my clients too. Well, there are many users are waiting for this
   issue to be solved.
 *  [ulicgn](https://wordpress.org/support/users/ulicgn/)
 * (@ulicgn)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17559791)
 * For all of you being referred to the ORM methods for saving, see here:
   [https://wordpress.org/support/topic/orm-examples-not-working-as-described/](https://wordpress.org/support/topic/orm-examples-not-working-as-described/)
 * So it seems as if currently both methods do not work as stated in the docs. 
   
   I would be interested whether there actually IS a working method to change/update
   an existing event that has been created previously and has been visible already.
 * Regards
 * Ulrich
 *  Thread Starter Anonymous User 13711045
 * (@anonymized-13711045)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17559796)
 * I miss the old TEC. The fact that the ORM methods aren’t working and it’s known
   they aren’t working is crazy. I’m also having issues now where the event recurrences
   aren’t being deleted from the wp_tec_occurrences table when deleting a post. 
   Sheesh.
    -  This reply was modified 2 years, 2 months ago by Anonymous User 13711045.
 *  [shingen0810](https://wordpress.org/support/users/shingen0810/)
 * (@shingen0810)
 * [1 year, 12 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17824413)
 * Hi @thekendog ,
   This topic might be the hint to open your door… don’t you think?
   [https://wordpress.org/support/topic/post-was-published-but-not-published/page/2/#post-17824058](https://wordpress.org/support/topic/post-was-published-but-not-published/page/2/#post-17824058)
   I have now tested with this script (automatic created posts on the events calendar)
   and displayed the posts nicely.I am not sure inside of DB, since I have not checked
   it all…I would like to hear your opinion on this.All the best,

Viewing 12 replies - 16 through 27 (of 27 total)

[←](https://wordpress.org/support/topic/programatically-create-and-update-events/?output_format=md)
[1](https://wordpress.org/support/topic/programatically-create-and-update-events/?output_format=md)
2

The topic ‘Programatically Create and Update Events’ is closed to new replies.

 * ![](https://ps.w.org/the-events-calendar/assets/icon-256x256.gif?rev=2516440)
 * [The Events Calendar](https://wordpress.org/plugins/the-events-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar/reviews/)

 * 27 replies
 * 9 participants
 * Last reply from: [shingen0810](https://wordpress.org/support/users/shingen0810/)
 * Last activity: [1 year, 12 months ago](https://wordpress.org/support/topic/programatically-create-and-update-events/page/2/#post-17824413)
 * Status: resolved