• Resolved woozys

    (@woozys)


    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/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter woozys

    (@woozys)

    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

    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/

    Thread Starter woozys

    (@woozys)

    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.

    you can also do it similar with events-manager/em-install.php at around line 178

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    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

    (@woozys)

    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!

    how about using $EM_Location = new EM_Location(); instead ? then using @marcus sample snippet above?

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    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

    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.