Skip to content

Commit 6c471e6

Browse files
authored
gcgs-gppa-custom-query-builder-args.php: Added instruction video and scoping to specific field-form IDs.
1 parent b54aa15 commit 6c471e6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

gc-google-sheets/gcgs-gppa-custom-query-builder-args.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
/**
33
* Gravity Connect // Google Sheets // Custom Query Build Arguments
44
*
5+
* Instruction Video: https://www.loom.com/share/a7bf1139baef48fc8b9b31209827cd17
6+
*
57
* This snippet customizes the generation of query builder arguments for Google Sheets queries.
68
*
79
* Installation:
810
* 1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
911
*/
1012
add_filter( 'gcgs_gppa_query_builder_args', function( $query_builder_args, $args, $object ) {
13+
1114
/** @var string|string[] */
1215
$filter_value = null;
1316

@@ -20,9 +23,21 @@
2023
/** @var string */
2124
$property_id = null;
2225

26+
/** @var object */
27+
$field = null;
28+
2329
// phpcs:ignore WordPress.PHP.DontExtract.extract_extract
2430
extract( $args );
2531

32+
// UPDATE 1 to your targeted field ID.
33+
$target_field_id = '1';
34+
// UPDATE 2 to your targeted form ID.
35+
$target_form_id = '2';
36+
37+
if ( $field->id != $target_field_id || $field->formId != $target_form_id || $filter['operator'] != 'is' ) {
38+
return $query_builder_args;
39+
}
40+
2641
$column_letter = $object->get_column_letter( $args['primary_property_value'], $property_id );
2742

2843
if ( ! empty( $filter_value ) ) {
@@ -32,7 +47,7 @@
3247
if ( ! empty( $v ) ) {
3348
$conditions[] = sprintf( "lower(%s) = '%s'", $column_letter, strtolower( $v ) );
3449
}
35-
}
50+
}
3651

3752
// Implode the conditions array with ' OR ' to form the $clause.
3853
$query_builder_args['where'][ $filter_group_index ][ $filter_group_index ] = implode( ' OR ', $conditions );

0 commit comments

Comments
 (0)