Delete entries after add-ons execution

Hi
I’d like to know if there’s an action that permit to delete entries (or do something) after add-ons execution.
I have added an action which delete entries “after_submission”, but it create issues with add-ons (execute the first add-on, generate a php error as the entry has been deleted so it can’t update meta, and then stop, so other add-ons are not executed).
I use mailchimp and webhooks add-ons.

It sounds like the issue you’re experiencing is related to the order of execution of the add-ons in relation to the deletion of the entries. When an entry is deleted using the after_submission hook, it’s possible that some add-ons that rely on that entry may not work correctly.

One way to solve this problem is to delay the execution of the deletion until after all the add-ons have finished processing the entry. You can achieve this by using a scheduled event or a queue system.

Here’s an example using a scheduled event:

  1. Add a new action that hooks into the gform_after_submission action, triggered after all add-ons have processed the entry.

  2. Schedule a new event to run a few seconds later in further action. This can be done using the wp_schedule_single_event function. Pass the ID of the entry to the scheduled event as an argument.

  3. In the scheduled event, retrieve and delete the entry using its ID.

This way, all add-ons have had a chance to process the entry before it’s deleted. It’s important to note that some add-ons may still rely on the entry being present for a short period after the gform_after_submission hook is triggered, so you may need to adjust the delay time accordingly.

Alternatively, you can use a queue system to delay the deletion of entries. When submitting an entry, add it to a queue instead of deleting it immediately. Then, a separate process reads from the queue and deletes entries after a predetermined delay.

I hope this helps you resolve the issue you’re experiencing!

We also have a documentation article covering some other methods:

1 Like

Thanks i will try to find a solution

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