WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Insert location data with functions (6 posts)

  1. TxemaLeon
    Member
    Posted 6 months ago #

    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?

    http://wordpress.org/plugins/events-manager/

  2. caimin_nwl
    NetWebLogic Support
    Posted 6 months ago #

    Hi,

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

  3. TxemaLeon
    Member
    Posted 6 months ago #

    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.

  4. angelo
    NetWebLogic Support
    Posted 6 months ago #

    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

  5. TxemaLeon
    Member
    Posted 6 months ago #

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

    $EM_Location->set_status(0);
    $EM_Location->save();
    $EM_Location->save_meta();

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

  6. TxemaLeon
    Member
    Posted 6 months ago #

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

    $EM_Location->save();
    $EM_Location->save_meta();
    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.

Reply

You must log in to post.

About this Plugin

About this Topic