Skip to content

Commit 0349ef4

Browse files
dariospacespivurno
authored andcommitted
Update gppa-custom-gf-entry-query-cache.php (#480)
* Update gppa-custom-gf-entry-query-cache.php updated snippet code to match the correct filter * Update gppa-custom-gf-entry-query-cache.php * Update gppa-custom-gf-entry-query-cache.php
1 parent eed218d commit 0349ef4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

gp-populate-anything/gppa-custom-gf-entry-query-cache.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
* Gravity Perks // GP Populate Anything // Custom GF_Entry Query Cache
44
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
55
*
6-
* This filter may improve performance but is known to return incorrect results when multiple fields are populated and chained to each other.
6+
* This may improve performance but is known to return incorrect results when multiple fields are populated and chained to each other.
77
*/
8-
// Replace "123" with your form ID and "4" with your field ID.
9-
add_filter( 'gppa_query_limit_123_4', function() {
10-
// Update "1000" to whatever you would like the query limit to be.
11-
return 1000;
12-
} );
8+
add_filter( 'gppa_query_cache_hash', function( $query_cache_hash, $object_type, $args ) {
9+
if ( $object_type === 'gf_entry' ) {
10+
return sha1( sprintf( '%s-%s-%s-%s-%s',
11+
$args['field']->formId,
12+
json_encode( $args['filter_groups'] ),
13+
json_encode( $args['ordering'] ),
14+
json_encode( $args['primary_property_value'] ),
15+
json_encode( $args['unique'] )
16+
) );
17+
}
18+
return $query_cache_hash;
19+
}, 10, 3 );

0 commit comments

Comments
 (0)