From: Chuck Scott Date: Mon, 10 Apr 2017 16:24:31 +0000 (-0400) Subject: Added shortcode option "type" for member types. X-Git-Tag: v2.9.15^2~47 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=e81db8bbae09f6babef3c6ca28f5af0cc79ed6d3;p=WP-Plugins%2Fglm-member-db.git Added shortcode option "type" for member types. Added ID column to member types admin list. Added "type" option to shortcode help info. --- diff --git a/models/front/members/list.php b/models/front/members/list.php index 843248bf..2ea2c54e 100644 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -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 diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 743a8b8b..9d146f50 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -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. + +   + + type="{ member type ID(s) }" + + + 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. + +   @@ -200,11 +214,11 @@ if ( isset( $config['settings'] ) && $config['settings']['enable_members'] ) { 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. diff --git a/views/admin/settings/index.html b/views/admin/settings/index.html index e43dc6c5..ab22e290 100644 --- a/views/admin/settings/index.html +++ b/views/admin/settings/index.html @@ -74,6 +74,7 @@ + @@ -88,6 +89,7 @@ {else} {/if} +
ID {$terms.term_member_cap} Type Description  
{$t.id} {$t.name}