Introduction
Most Gravity Forms add-on feeds are processed asynchronously, with no guaranteed order. That’s usually fine, but when one feed needs data produced by another, the order matters.
A Common Example
A form that uses the Advanced Post Creation Add-On to create a post and then sends the entry data, including the new post ID, to Zapier using the Zapier Add-On. Sometimes it works. Other times, Zapier receives the page ID instead of the post ID, and downstream automation breaks.
This article explains why that happens and how to work around it.
Why the Timing Matters
Because feeds run asynchronously, the Zapier feed can fire before the Advanced Post Creation feed has finished. This can impact the data Zapier receives from your site. For example, if you need the ID of the post being created by the Advanced Post Creation Add-On, you need Zapier to grab the data after the Advanced Post Creation feed has completed.
The workaround is to hold the dependent feed until the feed it relies on has completed, then trigger it manually.
The Approach
Two hooks, used together, make this work:
gform_is_delayed_pre_process_feed tells Gravity Forms to hold the Zapier feed until the post ID is available in the entry.
gform_advancedpostcreation_post_after_creation fires after the post has been created, which is the moment to trigger the delayed Zapier feed.
The code snippets for this workaround are available on the hook reference pages linked above. See the examples section of each page for the relevant code.
Adapting This to Other Add-Ons
This pattern isn’t limited to Advanced Post Creation and Zapier. Any time a feed needs to wait for another feed to finish first, the same approach applies: use gform_is_delayed_pre_process_feed to hold the dependent feed, then hook into an action that fires when the first feed completes, and trigger the delayed feed with GFAPI::maybe_process_feeds().
The gform_is_delayed_pre_process_feed hook reference has several other examples, including delaying Mailchimp until User Registration completes, delaying Slack mid User Registration, and delaying Zapier until a Dropbox upload finishes.