Disable GFML gform_pre_render callback

Bypass processing forms with Gravity Forms Multilingual when pulling results for Populate Anything via AJAX.

The reason for this is due to the ‘gform_pre_render’ method in Gravity_Forms_Multilingual using a runtime cache to cache all forms which interferes with Populate Anything.

Instructions

  1. https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
  2. Update the $form_ids_to_skip_gfml variable accordingly.

Code

Filename: gppa-disable-gfml-pre-render-callback.php

<?php
/**
 * Gravity Perks // Populate Anything // Disable GFML gform_pre_render callback
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * Bypass processing forms with Gravity Forms Multilingual when pulling results for Populate Anything via AJAX.
 *
 * The reason for this is due to the 'gform_pre_render' method in Gravity_Forms_Multilingual using a runtime cache to
 * cache all forms which interferes with Populate Anything.
 *
 * Instructions:
 *  1. https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
 *  2. Update the $form_ids_to_skip_gfml variable accordingly.
 */
add_action( 'init', function () {

	// Update the form IDs below
	$form_ids_to_skip_gfml = array( 123, 456 );

	if ( ! isset( $GLOBALS['wpml_gfml_tm_api'] ) || ! wp_doing_ajax() ) {
		return;
	}

	if ( ! function_exists( 'gp_populate_anything' ) || ! function_exists( 'rgar' ) ) {
		return;
	}

	if ( rgar( $_REQUEST, 'action' ) !== 'gppa_get_batch_field_html' ) {
		return;
	}

	$data = gp_populate_anything()::maybe_decode_json( WP_REST_Server::get_raw_data() );

	if ( ! in_array( rgar( $data, 'form-id' ), $form_ids_to_skip_gfml ) ) {
		return;
	}

	remove_filter( 'gform_pre_render', array( $GLOBALS['wpml_gfml_tm_api'], 'gform_pre_render' ) );

} );

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.