Fix for member category assigned in shortcode
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 8 Oct 2015 19:21:22 +0000 (15:21 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 8 Oct 2015 19:21:22 +0000 (15:21 -0400)
Update so if they turn off the search by category it will still look at
the shortcode category attr to filter the member list.

models/front/members/list.php

index 88ad297..4caf770 100644 (file)
@@ -139,32 +139,32 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
             foreach ($categoryData as $k=>$v) {
                 $categoryData[$k]['default'] = false;
             }
+        }
+        // Check if a category has been submitted
+        if (isset($_REQUEST['categorySearch'])) {
+            $catSelected = $_REQUEST['categorySearch'] - 0;
+        } elseif ($actionData['request']['category']) {
+            $catSelected = $actionData['request']['category'];
+        }
 
-            // Check if a category has been submitted
-            if (isset($_REQUEST['categorySearch'])) {
-                $catSelected = $_REQUEST['categorySearch'] - 0;
-            } elseif ($actionData['request']['category']) {
-                $catSelected = $actionData['request']['category'];
-            }
-
-            // If we have a category ID
-            if ($catSelected > 0) {
+        // If we have a category ID
+        if ($catSelected > 0) {
 
-                $where .= $whereSep." 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($catSelected)
-                           OR (C.parent in($catSelected) AND M.category = C.id)
-                )";
-                $whereSep = ' AND ';
+            $where .= $whereSep." 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($catSelected)
+                        OR (C.parent in($catSelected) AND M.category = C.id)
+            )";
+            $whereSep = ' AND ';
 
-                // Set default to true for the selected category
-                $c = explode(',', $catSelected);
-                $categoryData[$c[0]]['default'] = true;
+            // Set default to true for the selected category
+            $c = explode(',', $catSelected);
+            $categoryData[$c[0]]['default'] = true;
 
-            }
         }
+        
 
         // Get amenity filter data
         $amenityData = false;
@@ -228,7 +228,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
         /*
          *  Get a current list of members
          */
-
+        
         // Get member list and sort
         $list = $this->getList($where.$alphaWhere, 'member_name');