Add shortcode attribute for members.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 5 Sep 2019 18:56:52 +0000 (14:56 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 5 Sep 2019 18:56:52 +0000 (14:56 -0400)
Can setup the members list shortcode to display certain members by their
id's comma separated.

models/front/members/list.php
setup/shortcodes.php

index 27cadbf..cc1ba78 100755 (executable)
@@ -449,12 +449,32 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
 
             // Get cities for possible use in search pick list for cities used in active member info records.
             require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php';
-            $cities = new GlmDataCities($this->wpdb, $this->config);
+            $cities   = new GlmDataCities($this->wpdb, $this->config);
             $cityData = $cities->getListForSearch( true, $actionData );      // Get only categories that are used in active member data
 
+            // If we have members set in shortcode
+            $members = array();
+            if ( isset( $actionData['request']['members'] ) && $actionData['request']['members'] ) {
+                // Convert to array of member id's
+                $membersRequested = explode( ',', $actionData['request']['members'] );
+
+                // Check for numeric ID's only
+                foreach ( $membersRequested as $member ) {
+                    if ( $member_id = filter_var( $member, FILTER_VALIDATE_INT ) ) {
+                        $members[] = $member_id;
+                    }
+                }
+
+                // If not empty add to the $where
+                if ( !empty( $members ) ) {
+                    $where .= $whereSep . " T.member IN (" . implode( ',', $members ) . ")";
+                    $whereSep = ' AND ';
+                }
+            }
+
             // If we have a region set in shortcode or via URL.
             $regions = array();
-            if ( isset( $actionData['request']['region-search'] ) && $actionData['request']['region-search']) {
+            if ( isset( $actionData['request']['region-search'] ) && $actionData['request']['region-search'] ) {
 
                 // Convert comma separated list to an array
                 $regionsRequested = explode( ',', $actionData['request']['region-search'] );
index 1720e33..c713e6f 100644 (file)
@@ -81,6 +81,7 @@ if ( isset( $config['settings'] ) && $config['settings']['enable_members'] ) {
                 'cacheTime' => '2 WEEK' // MySQL "DATE_ADD" time interval - see https://www.w3schools.com/sql/func_date_add.asp
             ),
             'attributes'   => array(
+                'members'               => false,
                 'type'                  => false,
                 'category'              => false,
                 'category-name'         => false,
@@ -258,6 +259,19 @@ if ( isset( $config['settings'] ) && $config['settings']['enable_members'] ) {
                 the attributes below may used to modify the display of this page.
             </td>
         </tr>
+        <tr>
+            <td>&nbsp;</td>
+            <th>
+                members="{ member ID(s) }"
+            </th>
+            <td>
+                The "members" attribute is used to set the default display of members
+                to only one or more members by specifying the IDs.
+                To select multiple types, separate the IDs with a ",".
+                The ID for each member is shown in the "Members" list in the
+                admin "Settings" menu.
+            </td>
+        </tr>
         <tr>
             <td>&nbsp;</td>
             <th>
@@ -265,7 +279,7 @@ if ( isset( $config['settings'] ) && $config['settings']['enable_members'] ) {
             </th>
             <td>
                 The "type" attribute is used to set the default display of members
-                to only one or more member types by specifying the category IDs.
+                to only one or more member types by specifying the Type IDs.
                 To select multiple types, separate the IDs with a ",".
                 The ID for each member type is shown in the "Member Types" list in the
                 admin "Settings" menu.