From 1ebe1f1c6c4bd5830b59ab929d7720afa51bfd51 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Mon, 1 May 2017 08:45:34 -0400 Subject: [PATCH] modifiying the search filter in the functions file to make the query for categories an AND instead of OR looping through the categories to append a query clause for categories to make it search for AND instead of OR for each header search category option. The glm-member-db-front-search-query is where the changes were made --- functions.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/functions.php b/functions.php index f98bcac..7db25d2 100644 --- a/functions.php +++ b/functions.php @@ -24,14 +24,18 @@ add_filter('glm-member-db-front-search-query', function( $queryParts ) { //$queryParts = array(); if ( isset( $_REQUEST['categories'] ) && is_array( $_REQUEST['categories'] ) && !empty( $_REQUEST['categories'] ) ) { - $catSelectedForQuery = implode( ',',array_filter( $_REQUEST['categories'] )); - $queryParts[] = " T.id in ( +// $catSelectedForQuery = implode( ',',array_filter( $_REQUEST['categories'] )); + foreach( $_REQUEST['categories'] as $cat ){ + if( $cat !== ''){ + $queryParts[] = " T.id in ( SELECT DISTINCT(member_info) FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info M, ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories C - WHERE M.category in ($catSelectedForQuery) + WHERE M.category = $cat - ) "; + ) "; + } + } } if ( isset( $_REQUEST['cities'] ) && is_array( $_REQUEST['cities'] ) && !empty( $_REQUEST['cities'] ) && $_REQUEST['cities'][0] !== '' ) { -- 2.17.1