Added shortcode option "type" for member types.
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 10 Apr 2017 16:24:31 +0000 (12:24 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 10 Apr 2017 16:24:31 +0000 (12:24 -0400)
Added ID column to member types admin list.
Added "type" option to shortcode help info.

models/front/members/list.php
setup/shortcodes.php
views/admin/settings/index.html

index 843248b..2ea2c54 100644 (file)
@@ -356,6 +356,32 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
             }
         }
 
+        // Get any numeric member types selected in the submitted shortcode and add to $types array.
+        // We are currently only doing type selection by ID in the shortcode. No search parameters.
+        $typesSelected = '';
+        $types = array();
+        if (isset($actionData['request']['type'])) {
+
+            // Convert comma separated list to an array
+            $typesRequested = explode(',', $actionData['request']['type']);
+
+            // Check for numeric IDs only
+            while (list($k, $v) = each($typesRequested)) {
+
+                // If it's just numeric - note Explode returns an array element with value = 0 if no string.
+                if (preg_match('/^[0-9]*$/', trim($v)) && $v > 0) {
+
+                    // Clean up the type ID number and add to types array
+                    $types[] = ($v-0);
+
+                }
+
+            }
+
+        }
+        $typeSelected = implode(',', $types);
+        $typeSelectedForQuery = $typeSelected;
+
         // Get category data for possible use in search pick list for categories used in active member info records.
         require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php';
         $Categories = new GlmDataCategories($this->wpdb, $this->config);
@@ -479,9 +505,18 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
 
         }
 
-        // If we have a category ID or IDs
-        if ($catSelectedForQuery != '') {
+        // If we have a member type IDs - Add that to the where clause
+        if ($typeSelectedForQuery != '') {
+            $where .= $whereSep." T.member in (
+                SELECT DISTINCT(id)
+                 FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members
+                WHERE member_type in ($typeSelectedForQuery)
+            )";
+            $whereSep = ' AND ';
+        }
 
+        // If we have a category ID or IDs - Add that to the where clause
+        if ($catSelectedForQuery != '') {
             $where .= $whereSep." T.id in (
                     SELECT DISTINCT(member_info)
                       FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."category_member_info M,
@@ -490,7 +525,6 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                         OR (C.parent in($catSelectedForQuery) AND M.category = C.id)
             )";
             $whereSep = ' AND ';
-
         }
 
         // Get amenity filter data
index 743a8b8..9d146f5 100644 (file)
@@ -70,6 +70,7 @@ if ( isset( $config['settings'] ) && $config['settings']['enable_members'] ) {
             'action'       => 'list',
             'table'        => GLM_MEMBERS_PLUGIN_DB_PREFIX.'settings_general',
             'attributes'   => array(
+                'type'                  => false,
                 'category'              => false,
                 'category-name'         => false,
                 'category-search'       => false,
@@ -193,6 +194,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>
+                type="{ member type ID(s) }"
+            </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 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.
+            </td>
+        </tr>
         <tr>
             <td>&nbsp;</td>
             <th>
@@ -200,11 +214,11 @@ if ( isset( $config['settings'] ) && $config['settings']['enable_members'] ) {
             </th>
             <td>
                 The "category" attribute is used to set the default display of members
-                to only those mnembers in a specific category or categories by specifying
+                to only those members in a specific category or categories by specifying
                 the category IDs. To select multiple categories, separate the categories with a ",".
                 Categories are specified by ID number. The ID for each category is
                 shown in the Member Categories list. The selection of which members
-                to display may be overridded by the "category-search" parameter although
+                to display may be overridden by the "category-search" parameter although
                 these categories will always show in the list of categories that may be
                 selected in the search filter form.
             </td>
index e43dc6c..ab22e29 100644 (file)
@@ -74,6 +74,7 @@
     <table class="wp-list-table widefat fixed posts glm-admin-table">
         <thead>
             <tr>
+                <th>ID</th>
                 <th>{$terms.term_member_cap} Type</th>
                 <th>Description</th>
                 <th>&nbsp;</th>
@@ -88,6 +89,7 @@
         {else}
             <tr class="alternate">
         {/if}
+                <td>{$t.id}</td>
                 <td>
                     <a class="editMemberType" data-memberTypeID="{$t.id}">{$t.name}</a>
                 </td>