Title: Insert Event with PHP?
Last modified: August 20, 2016

---

# Insert Event with PHP?

 *  Resolved [theqwertman](https://wordpress.org/support/users/theqwertman/)
 * (@theqwertman)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/insert-event-with-php/)
 * Hello. I’m a new webadmin for a site that’s been using Events Manager for a while.
   There’s a function in the custom theme, scheduled to run via WordPress’ cron,
   that imports events from an external application called EMS. It used to work 
   by inserting rows into the em_events table, but after an events manager update,
   this isn’t working. The rows are inserted, but the events don’t appear in the
   interface.
 * I decided to go about things scientifically: I did a db backup right before and
   right after inserting a new event. I noticed that the changes to the database
   included a new row in em_events, a new row in posts, and a bunch of meta. I found
   it surprising that such a well used, well supported plugin writes information
   to the database in two different places. This seems like bad practice as far 
   as what I’ve learned.
 * That aside, I added code to the script to insert a post and meta based on the
   imported event as well, they’re still not showing up in the interface. My email
   logs don’t indicate any errors.
 * I searched high and low, even on the official Events Manager website, for some
   sort of documentation on a function I can use to add events without re-creating
   code that already exists in the plugin. I couldn’t find anything, only functions
   for reading and filtering events. I was hoping someone could point me in the 
   right direction, because the direct database inserts are improper, and they’re
   not working.
 * I could search through the EM code itself for such a function, but there are 
   other tasks I need to complete that have greater importance. If anyone wants 
   to take a look at my custom import code, I’ll gladly post it.
 * [http://wordpress.org/extend/plugins/events-manager/](http://wordpress.org/extend/plugins/events-manager/)

Viewing 1 replies (of 1 total)

 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/insert-event-with-php/#post-3501304)
 * hi,
 * maybe this snippet can help or give you an idea – [http://pastebin.com/3UDjZ8Le](http://pastebin.com/3UDjZ8Le)
   or you can try to hook into em_event_save filter

Viewing 1 replies (of 1 total)

The topic ‘Insert Event with PHP?’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 2 participants
 * Last reply from: [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/insert-event-with-php/#post-3501304)
 * Status: resolved