Last active
September 18, 2024 22:08
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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