Add filter for the member search.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 14 Apr 2017 17:46:09 +0000 (13:46 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 14 Apr 2017 17:46:09 +0000 (13:46 -0400)
This is to get the manufacturers into the member search as categories.

functions.php

index abb7dbc..7c69d9a 100644 (file)
@@ -27,6 +27,20 @@ add_filter('manufacturer_ids', function(){
 
    return $ids;
 });
+add_filter('glm-member-db-front-search-query', function() {
+    $queryParts = array();
+    if ( isset( $_REQUEST['manufacturers'] ) && is_array( $_REQUEST['manufacturers'] ) && !empty( $_REQUEST['manufacturers'] ) ) {
+        $catSelectedForQuery = implode( ',', $_REQUEST['manufacturers'] );
+        $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)
+                        OR (C.parent in($catSelectedForQuery) AND M.category = C.id)
+            ) ";
+    }
+    return $queryParts;
+});
 /**
  * Return the client info option for the given key
  *