From 2556aad198cbe9fabf2bd43b63319d5e130a25b9 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 13 Apr 2017 17:21:34 -0400 Subject: [PATCH] Update the filter for the search query for text and textarea. Only had the checkbox in there. Adding the search part for text and textarea to do like search. --- setup/frontHooks.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 557bcbc..ed4f1b7 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -55,6 +55,18 @@ add_filter('glm-member-db-front-search-query', function() { switch ( $field['field_type'] ) { case 'text': case 'textarea': + $field_name = preg_replace( '/[ -]/', '_', strtolower( $field['field_name'] ) ); + if ( isset( $_REQUEST[$field_name] ) && filter_var( $_REQUEST[$field_name], FILTER_SANITIZE_STRING ) ) { + $textSearch = $this->wpdb->esc_like( $_REQUEST[$field_name] ); + $queryParts[] = " T.id IN ( + SELECT ref_dest + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data + WHERE field_data like '%" . $textSearch . "%' + AND field_id = (SELECT id + FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields + WHERE field_name = '" . esc_sql( $field['field_name'] ) . "') + ) "; + } break; case 'checkbox': -- 2.17.1