Created
December 29, 2017 16:09
-
-
Save robin-scott/df3ab8fbe459619e0405867700ac1399 to your computer and use it in GitHub Desktop.
Remove Gravity forms fields in a specific form
This file contains 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
// Robin Scott added this here for use in SiliconDales.com, but the snippet comes from Gravity Forms docs, here: https://docs.gravityforms.com/gform_export_fields/ | |
add_filter( 'gform_export_fields', function ( $form ) { | |
// only limit the fields available for export form form ID 3 | |
if ( $form['id'] == 3 ) { | |
// array of field IDs I never want to see on the export page | |
$fields_to_remove = array( | |
'payment_amount', | |
'payment_date', | |
'payment_status', | |
'transaction_id', | |
'user_agent', | |
'ip', | |
'post_id' | |
); | |
foreach ( $form['fields'] as $key => $field ) { | |
$field_id = is_object( $field ) ? $field->id : $field['id']; | |
if ( in_array( $field_id, $fields_to_remove ) ) { | |
unset ( $form['fields'][ $key ] ); | |
} | |
} | |
} | |
// always return the form | |
return $form; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment