Hide Product Fields on Edit

Code

Filename: gpeb-hide-product-fields-on-edit.php

<?php
/**
 * Gravity Perks // Entry Blocks // Hide Product Fields on Edit
 * https://gravitywiz.com/documentation/gravity-forms-entry-blocks/
 */
add_filter( 'gform_pre_render', function( $form ) {
	if ( ! class_exists( 'WP_Block_Supports' ) || rgar( WP_Block_Supports::$block_to_render, 'blockName' ) !== 'gp-entry-blocks/edit-form' ) {
		return $form;
	}
	$filtered_fields = array();
	foreach ( $form['fields'] as &$field ) {
		if ( ! GFCommon::is_product_field( $field->type ) ) {
			$filtered_fields[] = $field;
		}
	}
	$form['fields'] = $filtered_fields;
	return $form;
} );

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.