From bbdf5a34b6f57ef88a4d36c186e271f7184e10ea Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 5 Sep 2019 14:56:52 -0400 Subject: [PATCH] Add shortcode attribute for members. Can setup the members list shortcode to display certain members by their id's comma separated. --- models/front/members/list.php | 24 ++++++++++++++++++++++-- setup/shortcodes.php | 16 +++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/models/front/members/list.php b/models/front/members/list.php index 27cadbf5..cc1ba787 100755 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -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'] ); diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 1720e33e..c713e6fd 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -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. + +   + + members="{ member ID(s) }" + + + 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. + +   @@ -265,7 +279,7 @@ if ( isset( $config['settings'] ) && $config['settings']['enable_members'] ) { 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. -- 2.17.1