Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Last active December 15, 2021 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/2750a6c2cfa034580c0e3cf519f4c8bf to your computer and use it in GitHub Desktop.
Save zackkatz/2750a6c2cfa034580c0e3cf519f4c8bf to your computer and use it in GitHub Desktop.
GravityView Entry Revisions - Modify Ignored Fields
<?php
/**
* Modify the fields shown for entry revisions for Form #17
*
* @param array $ignored_keys Array of entry meta keys and field IDs to not display in the diff, for example [ 'id', 'date_updated', '1.2' ].
* @param array $form Gravity Forms form array.
*
* @returns array $ignored_keys with added fields to ignore.
*/
add_filter( 'gravityview/entry-revisions/diff-ignored-keys', function( $ignored_keys, $form ) {
if ( empty( $form ) ) {
return $ignored_keys;
}
// Only run this filter for Form #17
if ( 17 !== (int) $form['id'] ) {
return $ignored_keys;
}
$ignored_keys[] = '1'; // Don't show Field #1
$ignored_keys[] = '2.2'; // Don't show the second input on field #2
return $ignored_keys;
}, 10, 2 );
@marklamb20
Copy link

marklamb20 commented Nov 30, 2020

Hey sir, i tried your snippet but it didn't work for me in the frontend.

I change my form id and field id but it did not do anything. Can you please confirm if it works?

@tazeverywhere
Copy link

tazeverywhere commented Dec 15, 2021

Same here on frontend, using ID of fields doesn't seems to work.

@tazeverywhere
Copy link

Ok found it, field ids must be of type int, not string.. adding quote doesn't work.
image

@zackkatz
Copy link
Author

Thanks @tazeverywhere; the next update will fix the issue where int or float are required.

@tazeverywhere
Copy link

tazeverywhere commented Dec 15, 2021

Thanks to you @zackkatz , very useful plugin! Using it with gravity-flow is a must.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment