Advanced Post Creation - getting the new post IDS

Hello,
We are using Advanced Post Creation which creates 3 posts to 3 different post types. We are using gform_advancedpostcreation_post_after_creation to try to get the new Post IDs.

Currently it’s returning the ID of the first created post. I understand that an array is being returned.

How can I return all the Post IDs, and then distinguish between them so that I can run an action specific to the post type? In other words if 3 IDs are returned, what is a way to know which post or post type they are actually associated with?

Thank you in advance for your help, it’s greatly appreciated.

Hi Frazier. To get the post IDs, you can use this code with the gform_advancedpostcreation_post_after_creation hook:

// If the Advanced Post Creation add-on is used, more than one post may be created for a form submission
// the post ids are stored as an array in the entry meta
$created_posts = gform_get_meta( $entry['id'], 'gravityformsadvancedpostcreation_post_id' );
foreach ( $created_posts as $post ){
    $post_id = $post['post_id'];
    // Do your stuff here.
}

That code can be found in the example here.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.