Hooking into new listing saved

This topic contains 3 replies, has 3 voices, and was last updated by  Kiran 5 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #485474

    TLN
    Expired Member
    Post count: 131

    Hi Guys,

    I’d like to do some stuff when a new listing is created (after it is successfully saved for the first time). Is there a specific hook for this?

    Thank you for your help.

    #485577

    Alex Rollin
    Moderator
    Post count: 27815

    Hi,

    thanks for your question. I will flag it for the developers to share more about that.

    #485769

    TLN
    Expired Member
    Post count: 131

    Please see below for my solution so far. Perhaps it will help somebody out.

    
    
    // executes when a listing is saved
    function on_save_listing( $post_id, $post, $update ) {
    
    // get the author id
    $author_id=$post->post_author;
    
    $updated = ($update) ? "updated" : "saved";
    	
    if ($updated=='saved') {
    // do what you need to do here
    // this will run when a gd_place post is saved
    }
    
    }
    add_action( 'save_post_gd_place', 'on_save_listing', 10, 3 );

    I ended up compensating since I don’t know when the listing is saved for the first time. Instead, i am using the following hook to do some more stuff when the listing is published (which should only happen once in theory).

    
    
    function on_publish_listing( $post_id, $post ) {
    
    //get author id
    $author_id=$post->post_author;
    
    //do some stuff here..
    
    }
    add_action( 'publish_gd_place', 'on_publish_listing', 10, 2 );
    #486082

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
Viewing 4 posts - 1 through 4 (of 4 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket