Skip to content

Commit 3d56338

Browse files
authored
gpeb-hide-specific-fields-on-edit.php: Added new snippet for hiding specific fields when editing entrys via Entry Blocks.
1 parent fc582bf commit 3d56338

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Entry Blocks // Hide Specific Fields on Edit
4+
* https://gravitywiz.com/documentation/gravity-forms-entry-blocks/
5+
*/
6+
// Update "123" to your form ID.
7+
add_filter( 'gform_pre_render_123', function ( $form ) {
8+
// Update "4", "5", and "6" to the IDs of the fields you'd like to hide.
9+
$fields_to_hide = array( 4, 5, 6 );
10+
if ( ! class_exists( 'WP_Block_Supports' ) || rgar( WP_Block_Supports::$block_to_render, 'blockName' ) !== 'gp-entry-blocks/edit-form' ) {
11+
return $form;
12+
}
13+
$filtered_fields = array();
14+
foreach ( $form['fields'] as &$field ) {
15+
if ( ! in_array( $field->id, $fields_to_hide ) ) {
16+
$filtered_fields[] = $field;
17+
}
18+
}
19+
$form['fields'] = $filtered_fields;
20+
return $form;
21+
} );

0 commit comments

Comments
 (0)