How to search for an exact match

GravityView's current search functionality doesn't use exact match, so if you search for the word "Kansas", results containing that word, like "Arkansas", will also show up:

If you wish to change the search functionality to look for exact matches, then you need the function below:

add_filter( 'gravityview_search_operator', 'gv_change_search_operator', 10,2 );
function gv_change_search_operator( $operator, $filter = array() ){
	$view = gravityview_get_current_view_data();
	$view_id = $view['id'];
	if( $view_id == '8' ) { // CHANGE '8' TO YOUR OWN VIEW ID
		return 'is';
	}
}

Here's the end result:

If you need to target just a specific field from a specific form, then the code is a little bit more complex. To achieve that, we've created a simple plugin that you can download here. You'll need to modify the Form ID and Field IDs inside that plugin's code using the plugin editor on your WordPress Dashboard:

 Please contact our support if you need further assistance.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.