Enable asynchronous feed processing and notifications.

API requests to OpenAI can be quite slow given the amount of processing that is happening behind the scenes. To speed up form submission, we can make the feed asynchronous as well as the notifications.

Instructions

  1. Install per https://gravitywiz.com/how-do-i-install-a-snippet/
  2. Update FORMID accordingly.

Code

Filename: gfoai-async-feed.php

<?php
/**
 * Gravity Wiz // Gravity Forms OpenAI // Enable asynchronous feed processing and notifications.
 *
 * API requests to OpenAI can be quite slow given the amount of processing that is happening behind the scenes. To
 * speed up form submission, we can make the feed asynchronous as well as the notifications.
 *
 * Instructions:
 *  1. Install per https://gravitywiz.com/how-do-i-install-a-snippet/
 *  2. Update FORMID accordingly.
 */
add_filter( 'gform_is_asynchronous_notifications_enabled_FORMID', '__return_true' );
add_filter( 'gform_is_feed_asynchronous_FORMID', function( $is_async, $feed ) {
	// Only make feeds async if they have the slug of gravityforms-openai.
	if ( $feed['addon_slug'] === 'gravityforms-openai' ) {
		return true;
	}

	return $is_async;
}, 10, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.