Process shortcodes on Message Prompts

Processing of shortcodes on the message prompts is disabled by default. Use this snippet to enable it

Instructions

Code

Filename: gfoai-process-shortcodes-on-prompt.php

<?php
/**
 * Gravity Wiz // Gravity Forms OpenAI // Process shortcodes on Message Prompts
 *
 * Processing of shortcodes on the message prompts is disabled by default. Use this snippet to enable it
 *
 * Instructions:
 *  1. Install per https://gravitywiz.com/how-do-i-install-a-snippet/
 */
add_filter( 'gform_gravityforms-openai_pre_process_feeds', function ( $feeds, $entry ) {
	foreach ( $feeds as &$feed ) {
		// Process shortcode on chat completion message prompt
		if ( $feed['meta']['chat_completions_message'] ) {
			$feed['meta']['chat_completions_message'] = do_shortcode( $feed['meta']['chat_completions_message'] );
		}
	}

	return $feeds;
}, 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.