Created
July 29, 2021 17:41
-
-
Save zackkatz/7acb41577deae674916ec8cacb42cee2 to your computer and use it in GitHub Desktop.
GravityView - Exact-match search (not fuzzy) for a specific field and View
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
<?php | |
/** | |
* Return strict "is" comparison operator when processing a search on a specific View and field. | |
* | |
* @param string $operator Existing search operator | |
* @param array $filter array with `key`, `value`, `operator`, `type` keys | |
* @param \GV\View $view The View we're operating on. | |
* | |
* @return string | |
*/ | |
add_filter( 'gravityview_search_operator', function ( $operator, $filter, $view ) { | |
// Only run on /suggested-rule-change-comments/ | |
if( 7768 !== $view->ID ) { | |
return $operator; | |
} | |
if ( '7' === $filter['key'] ) { | |
return $operator; | |
} | |
return 'is'; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment