From 0cf18e9564b21b0a026c686265a10ed73b0acc43 Mon Sep 17 00:00:00 2001 From: Jarryd Long Date: Thu, 7 Apr 2022 14:18:38 +0200 Subject: [PATCH 1/3] Bug Fix: user_id shortcode attribute gets passed through Resolves #116 --- pmpro-member-directory.php | 11 +++++++---- templates/profile.php | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pmpro-member-directory.php b/pmpro-member-directory.php index ccf8e04..c3fc861 100644 --- a/pmpro-member-directory.php +++ b/pmpro-member-directory.php @@ -279,17 +279,20 @@ function pmpromd_get_user_by_identifier( $value ) { * @since 1.2.0 * */ -function pmpromd_get_user(){ +function pmpromd_get_user( $user_id = false){ - global $wp_query; + global $wp_query, $current_user; - if( !empty( $wp_query->get( 'pu' ) ) ){ + if( $user_id ) { + //We're specifying which user we want to display + $pu = get_user_by('id', intval( $user_id ) ); + } else if( !empty( $wp_query->get( 'pu' ) ) ){ //Using the new permalinks /profile/user $pu = pmpromd_get_user_by_identifier( $wp_query->get( 'pu' ) ); } elseif( !empty( $_REQUEST['pu'] ) ) { //Using old url structure /profile/?pu=user $pu = pmpromd_get_user_by_identifier( $_REQUEST['pu'] ); - } elseif( !empty( $current_user->ID ) ) { + } elseif( !empty( $current_user->ID ) ) { $pu = $current_user; } else { $pu = false; diff --git a/templates/profile.php b/templates/profile.php index b35e6d8..7198538 100644 --- a/templates/profile.php +++ b/templates/profile.php @@ -218,8 +218,7 @@ function pmpromd_profile_shortcode($atts, $content=null, $code="") elseif(empty($limit)) $limit = 15; - - $pu = pmpromd_get_user(); + $pu = pmpromd_get_user( $user_id ); if ( ! empty( $pu ) ) { $pu->membership_level = pmpro_getMembershipLevelForUser( $pu->ID ); From 28b8c24eb8dac6aada93df2dd353c60aed64c7e2 Mon Sep 17 00:00:00 2001 From: Andrew Lima Date: Thu, 7 Apr 2022 14:30:50 +0200 Subject: [PATCH 2/3] General WPCS and minor sanitization on retrieving. --- pmpro-member-directory.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pmpro-member-directory.php b/pmpro-member-directory.php index c3fc861..71e74ea 100644 --- a/pmpro-member-directory.php +++ b/pmpro-member-directory.php @@ -269,7 +269,7 @@ function pmpromd_get_user_by_identifier( $value ) { $user_identifier = pmpromd_user_identifier(); - return get_user_by( $user_identifier, $value ); + return get_user_by( $user_identifier, sanitize_text_field( $value ) ); } @@ -279,20 +279,20 @@ function pmpromd_get_user_by_identifier( $value ) { * @since 1.2.0 * */ -function pmpromd_get_user( $user_id = false){ +function pmpromd_get_user( $user_id = false ){ global $wp_query, $current_user; - if( $user_id ) { + if ( $user_id ) { //We're specifying which user we want to display - $pu = get_user_by('id', intval( $user_id ) ); - } else if( !empty( $wp_query->get( 'pu' ) ) ){ + $pu = get_user_by( 'id', intval( $user_id ) ); + } elseif ( ! empty( $wp_query->get( 'pu' ) ) ) { //Using the new permalinks /profile/user $pu = pmpromd_get_user_by_identifier( $wp_query->get( 'pu' ) ); - } elseif( !empty( $_REQUEST['pu'] ) ) { + } elseif ( ! empty( $_REQUEST['pu'] ) ) { //Using old url structure /profile/?pu=user $pu = pmpromd_get_user_by_identifier( $_REQUEST['pu'] ); - } elseif( !empty( $current_user->ID ) ) { + } elseif ( ! empty( $current_user->ID ) ) { $pu = $current_user; } else { $pu = false; From 89581d69e82cba5e9601f29778d3ce747f21e23b Mon Sep 17 00:00:00 2001 From: Andrew Lima Date: Thu, 7 Apr 2022 14:45:51 +0200 Subject: [PATCH 3/3] Version Bump / Minor Release 1.2.1 Bump version to 1.2.1 and update readme changelog. --- pmpro-member-directory.php | 4 ++-- readme.txt | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pmpro-member-directory.php b/pmpro-member-directory.php index 71e74ea..fc58569 100644 --- a/pmpro-member-directory.php +++ b/pmpro-member-directory.php @@ -3,14 +3,14 @@ Plugin Name: Paid Memberships Pro - Member Directory Add On Plugin URI: https://www.paidmembershipspro.com/add-ons/member-directory/ Description: Adds a customizable Member Directory and Member Profiles to your membership site. -Version: 1.2 +Version: 1.2.1 Author: Paid Memberships Pro Author URI: https://www.paidmembershipspro.com/ Text Domain: pmpro-member-directory Domain Path: /languages */ -define( 'PMPRO_MEMBER_DIRECTORY_VERSION', '1.0' ); +define( 'PMPRO_MEMBER_DIRECTORY_VERSION', '1.2.1' ); global $pmpromd_options; diff --git a/readme.txt b/readme.txt index 3dd54c8..9055986 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: strangerstudios Tags: pmpro, paid memberships pro, members, directory Requires at least: 4.0 Tested up to: 5.9 -Stable tag: 1.2 +Stable tag: 1.2.1 Add a robust Member Directory and Profiles to Your Membership Site - with attributes to customize the display. @@ -97,6 +97,11 @@ Please post it in the issues section of GitHub and we'll fix it as soon as we ca Please visit our premium support site at http://www.paidmembershipspro.com for more documentation and our support forums. == Changelog == += 1.2.1 - 2022-04-07 = +* ENHANCEMENT: Added small sanitization check for query parameter values. +* BUG FIX: Fixed issue where passing "user_id" attribute in shortcode was returning empty results. +* BUG FIX: Removed debug code that was causing minor output issues. + = 1.2 - 2022-03-31 = * ENHANCEMENT: General improvements to localization and translatable strings. * ENHANCEMENT: Improvement to profile pretty permalinks structure that's more SEO friendly (e.g. membership-account/profile/admin/). Automatically flush permalinks when needed in admin area.