Skip to content

gcgs-gppa-custom-query-builder-args.php: Added instruction video and scoping to specific field-form IDs. #1048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion gc-google-sheets/gcgs-gppa-custom-query-builder-args.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
/**
* Gravity Connect // Google Sheets // Custom Query Build Arguments
*
* Instruction Video: https://www.loom.com/share/a7bf1139baef48fc8b9b31209827cd17
*
* This snippet customizes the generation of query builder arguments for Google Sheets queries.
*
* Installation:
* 1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
*/
add_filter( 'gcgs_gppa_query_builder_args', function( $query_builder_args, $args, $object ) {

/** @var string|string[] */
$filter_value = null;

Expand All @@ -20,9 +23,21 @@
/** @var string */
$property_id = null;

/** @var object */
$field = null;

// phpcs:ignore WordPress.PHP.DontExtract.extract_extract
extract( $args );

// UPDATE 1 to your targeted field ID.
$target_field_id = '1';
// UPDATE 2 to your targeted form ID.
$target_form_id = '2';

if ( $field->id != $target_field_id || $field->formId != $target_form_id || $filter['operator'] != 'is' ) {
return $query_builder_args;
}

$column_letter = $object->get_column_letter( $args['primary_property_value'], $property_id );

if ( ! empty( $filter_value ) ) {
Expand All @@ -32,7 +47,7 @@
if ( ! empty( $v ) ) {
$conditions[] = sprintf( "lower(%s) = '%s'", $column_letter, strtolower( $v ) );
}
}
}

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