Support » Plugins and Hacks » [Resolved] Insert location data with functions

[Resolved] Insert location data with functions

  • Hi.

    I’m writing a plugin and I want it to insert posts with type location. I know how to do this and how to insert the custom fields with wp_insert_post() and add_metadata(), but I want it to also insert the address, city, etc.

    Is there any function provided with Events Manager or how could I achieve this?


Viewing 5 replies - 1 through 5 (of 5 total)
  • caimin_nwl


    NetWebLogic Support


    Do you want to put together something that works with Events Manager locations, or something that replicates the locations feature but is separate?

    Hi, I wanted to put locations in the database using the Events Manager functions, tables, etc, so it will work with the plugin.

    I’ve been able to do so with EM_Location->save() and EM_Location->save_meta(), and adding the post metadata with add_post_meta().

    What I need to do now is to use EM_Location->save and leave the post as pending, not as published. EM_Location->post_status = ‘pending’ does not work.



    NetWebLogic Support

    you can try to hook into em_location_set_status filter for this. for reference only, this is located under classes/em-location.php at around line 486 – 514

    And is there any easy way to do this? I’m trying to do


    But this is not working, nor is $EM_Location->set_status(‘pending’);

    Well, I found a patch solution, which is immediately after save_meta() downgrade the post to pending:

    wp_update_post( array( 'ID' => $EM_Location->post_id, 'post_status' => 'pending' ) );

    I find this to be the most elegant solution besides making the save in pending status. Not ideal though, if you can point me to something better, I’d thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Insert location data with functions’ is closed to new replies.