Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Last active September 18, 2024 22:08
Show Gist options
  • Save rafaehlers/408fa5cdbdf119e300a2612b4164f44e to your computer and use it in GitHub Desktop.
Save rafaehlers/408fa5cdbdf119e300a2612b4164f44e to your computer and use it in GitHub Desktop.
Hide field from GravityView's Edit Entry page when the Edit Entry layout is left empty in the View editor
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview/edit_entry/form_fields', function ( $gf_fields, $edit_entry_fields, $form, $view_id ) {
if ( 1 !== $view_id ) { // Replace 1 with the View ID you want to target.
return $gf_fields;
}
foreach ( $gf_fields as $index => $field ) {
if ( 2 === $field->id ) { // Replace 2 with the Field ID you want to hide.
unset( $gf_fields[ $index ] );
}
}
return $gf_fields;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment