Update the region-search actionData so it can be multiple id's
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 15 Sep 2016 16:06:17 +0000 (12:06 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 15 Sep 2016 16:06:17 +0000 (12:06 -0400)
Using example from the category one to apply the same algorithm to the
region-search arg in shortcode.

models/front/members/list.php

index 4dfad1a..9fbaf03 100644 (file)
@@ -406,9 +406,19 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
 
         // If we have a region
         if ($actionData['request']['region-search']) {
-            $regionSearch = $actionData['request']['region-search']-0;
-            if ($regionSearch > 0) {
-                $where .= $whereSep." T.region = $regionSearch";
+            $regions = array();
+            // Convert comma separated list to an array
+            $regionsRequested = explode( ',', $actionData['request']['region-search'] );
+
+            // Check for numeric ID's only
+            while ( list( $k, $v ) = each( $regionsRequested ) ) {
+                if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
+                    $regions[] = ( $v - 0 );
+                }
+            }
+
+            if ( isset( $regions ) && !empty( $regions ) ) {
+                $where .= $whereSep." T.region IN (" . implode( ',', $regions ) . ")";
                 $whereSep = ' AND ';
             }
         }