Action that has access to post id of new post created by Webhook Add-on [RESOLVED]

I’m using this guide to create an Event post using Gravity Forms and it works great:

The issue I have is using a function that works well for other forms creating standard Wordpress posts using the advanced post creation add on doesn’t work for the events.

The function uses the gform_after_submission to add some additional data to the post that was newly created but I can’t figure out how to access the post_id for the new post.

This is what I use for the Advanced post creation feeds:

$created_posts = gform_get_meta( $entry['id'], 'gravityformsadvancedpostcreation_post_id' );

You probably want to use the gform_advancedpostcreation_post_after_creation action.

Thanks for your reply Jamie, I’ve tried this but it doesn’t work. The post isn’t being created by the advanced post creation add on in this form - it is created by the Webhooks add on.

The gform_webhooks_post_request hook has the complete response to your webhook request:

In there, the post ID is probably available. I am not sure what you need to do with the post ID next, but you should have it there. If you need help with what’s next, please let us know.

That’s exactly it, thanks Chris. With some extra help from Richard from the GF support team I’ve got it working.

add_action( 'gform_webhooks_post_request', 'gw_child_entries_to_repeater_event', 10, 4 );
function gw_child_entries_to_repeater_event( $response, $feed, $entry, $form ) {

	$response_body_json = wp_remote_retrieve_body( $response );
	$response_body_array = json_decode( $response_body_json, true );
	$new_post_id = rgar( $response_body_array, 'id' );'

//Rest of function here
1 Like