Option to Delay PDF Generation After Submit Button has been Press

Gravity Forms
16 September, 2021 12:22:18
Topics: 1
Messages: 1
Hi Guys,

First off, Great Plugin - One of the best if not the best.

I have users filling out Gravity forms 20+ times per day and as we add new options to the gravity forms it now taking too long for the form submittion - in somes cases over 60 seconds. As you can imagine this is fustrating for the end users who are out on sites doing this on their iPads etc.

Can we look at getting a way to delay the PDF generation so it runs as a backgroud task to drastically speed up the submittion time.

Any feedback or a snippit to add this in would be great.

17 September, 2021 00:21:45
Topics: 7
Messages: 2450
Hi, thank you.

Unfortunately by default all notifications fires on form submission and due the way of PHP working - it will output "Success Message" and finish it only when all functions (including PDF generation and sending emails) will be completed.

There are some possible solutions:

1st possible solution: Build custom cron job by following the current logic:
- You add some hidden field inside form which by default for example has '0' as default value.
- You create "custom" action and connect notification to it, so after first submission emails will not be sent: https://docs.gravityforms.com/gform_notification_events/.
- Via custom cron job file (recommended) or wordpress cronjob functionality you get entries which has this hidden value set to '0', update hidden value to '1', trigger sending notification event via https://docs.gravityforms.com/api-functions/#send-notifications.

2nd possible solution: Use async emails plugin with WordPress or only for Gravity Forms (if possible). In this case all [e2pdf-attachment] shortcodes must be converted to [e2pdf-save id="1" attachment="true" overwrite="false"] as async emails will require PDF file to exist if it will be delayed output. In most cases such plugins using WordPress cron job functionality.

3rd possible solution: Try to optimize email actions but it could work only if you have multiple actions under Gravity Forms with same [e2pdf-attachment] shortcodes. For example you can try to use [e2pdf-save id="1" attachment="true" overwrite="false"] instead of [e2pdf-attachment id="1"]. PDF will be generated only 1 time, saved and exactly this saved PDF will be used as attachment for all other shortcodes with same attributes.

P.S. Keep attention please that if you will be using [e2pdf-save] shortcode - PDF Name must be set to unique name for each submission, for example it's possible to use {entry_id} as name (screenshot attached)

We remain at your service.

If you appreciate our support , we would really appreciate your feedback at WordPress.org!