Title: Submit Events/Locations through API
Last modified: August 20, 2016

---

# Submit Events/Locations through API

 *  Resolved [woozys](https://wordpress.org/support/users/woozys/)
 * (@woozys)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/)
 * Hi there
 * I am wondering if it is possible to submit locations or events through Events
   Manager’s API?
 * The reason I am asking is because I want to run an automatic PHP script which
   would fill up my database with data from an external API.
 * Any help/tips would be highly appreciated.
 * Kind regards
    Tadas
 * [http://wordpress.org/extend/plugins/events-manager/](http://wordpress.org/extend/plugins/events-manager/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Thread Starter [woozys](https://wordpress.org/support/users/woozys/)
 * (@woozys)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569339)
 * Ok, I managed to import locations and relevant meta data with `wp_insert_post()`
   and `add_post_meta()` functions.
 * I can see locations fine in the front end, however, related location events are
   not shown because location was not transferred to `wp_em_locations` table and
   does not have a `location_id` assigned.
 * There must be a hook or action that I could perform to get the data into `wp_em_locations`
   table and get a `location_id`?
 * Thanks in advance
 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569368)
 * you can hook into em_location_save filter;
 * you can see this filter at classes/em-location.php
 * similar with [http://wp-events-plugin.com/tutorials/saving-custom-event-information/](http://wp-events-plugin.com/tutorials/saving-custom-event-information/)
 *  Thread Starter [woozys](https://wordpress.org/support/users/woozys/)
 * (@woozys)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569372)
 * Thanks, agelonwi.
 * If I understand correctly hooking into `em_location_save` filter like shown in
   the example would execute a custom function whenever location is saved.
 * What I want to do is to do whatever Events Manager would normally do (add wp_em_location
   row, etc.) whenever I insert a location. Is it necessary for me to rewrite this
   code in the form of a custom function myself, or is there a better way to trigger
   this action?
 * Many thanks for your help and pardon my lack of understanding.
 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569377)
 * you can also do it similar with events-manager/em-install.php at around line 
   178
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569392)
 * two ways… 1 (an easy way) is to use the section of code angelonwl pointed you
   to
 * otherwise, you need to create an EM_Location object, populate it, then run $EM_Location-
   >save();
 * Something like:
 *     ```
       $EM_Location = new EM_Location();
       $EM_Location->location_name = '123 Test Location;
       $EM_Location->location_address = '123 Test Address';
       //etc.
       $EM_Location->save();
       ```
   
 * see the class to view the properties you can set
 *  Thread Starter [woozys](https://wordpress.org/support/users/woozys/)
 * (@woozys)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569395)
 * Hi Marcus
 * Thanks! I achieved it by using the following:
 *     ```
       $EM_Location = new EM_Location($post_id, 'post_id');
       $EM_Location->save();
       return $EM_Location->location_id;
       ```
   
 * Even though it works, I get this error message every time I run the function:
 *     ```
       Strict Standards:  call_user_func_array() expects parameter 1 to be a valid callback, non-static method EM_Event_Post_Admin::save_post() should not be called statically in /homepages/45/d391709137/htdocs/eventhread.com/wordpress/wp-includes/plugin.php on line 406
       ```
   
 * Any tips?
 * Thanks so much for your help!
 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569408)
 * how about using `$EM_Location = new EM_Location();` instead ? then using [@marcus](https://wordpress.org/support/users/marcus/)
   sample snippet above?
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569423)
 * for a new event you shouldn’t supply any post ids or it’ll update that post id
   instead
 * it’s just a warning, no adverse effects, will look into fixing that next update
 *  [txemaleon](https://wordpress.org/support/users/txemaleon/)
 * (@txemaleon)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569555)
 * Is it possible to do this but to leave the posts as pending?

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Submit Events/Locations through API’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=1039078)
 * [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/)

 * 9 replies
 * 4 participants
 * Last reply from: [txemaleon](https://wordpress.org/support/users/txemaleon/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/submit-eventslocations-through-api/#post-3569555)
 * Status: resolved