spivurno
11/17/2016 - 10:35 PM

Gravity Perks // GP Preview Submission // Hide Hidden-visibility Fields from Preview (when :nohidden modifier is used)

Gravity Perks // GP Preview Submission // Hide Hidden-visibility Fields from Preview (when :nohidden modifier is used)

<?php
/**
 * Gravity Perks // GP Preview Submission // Hide Hidden-visibility Fields from Preview (when :nohidden modifier is used)
 * http://gravitywiz.com
 */
add_filter( 'gform_merge_tag_filter', function( $value, $merge_tag, $modifier, $field ) {

	if ( $merge_tag == 'all_fields' ) {
		$modifiers = explode( ',', $modifier );
		if( in_array( 'nohidden', $modifiers ) && $field->visibility == 'hidden' ) {
			return false;
		}
	}

	return $value;
}, 10, 4 );