This commit is contained in:
Mykyta Synelnikov
2024-04-24 02:42:44 +03:00
parent 74082f3781
commit dca31429db
3 changed files with 27 additions and 9 deletions
@@ -959,7 +959,8 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
} elseif ( 'last_login' === $sortby ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '_um_last_login' )";
$this->sql_order = ' ORDER BY CAST( umm_sort.um_value AS DATETIME ) DESC ';
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_show_login ON ( umm_show_login.user_id = u.ID AND umm_show_login.um_key = 'um_show_last_login' )";
$this->sql_order = $wpdb->prepare( ' ORDER BY CASE ISNULL(NULLIF(umm_show_login.um_value,%s)) WHEN 0 THEN %s ELSE CAST( umm_sort.um_value AS DATETIME ) END DESC ', 'a:1:{i:0;s:3:"yes";}', '1970-01-01 00:00:00' );
} elseif ( 'last_first_name' === $sortby ) {
+24 -8
View File
@@ -1464,17 +1464,33 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
} elseif ( 'last_login' === $sortby ) {
$this->query_args['orderby'] = array( 'um_last_login' => 'DESC' );
// Please use custom meta table for better results and sorting.
$this->query_args['meta_query'][] = array(
'relation' => 'OR',
'relation' => 'AND',
array(
'key' => '_um_last_login',
'compare' => 'EXISTS',
'type' => 'DATETIME',
'relation' => 'OR',
array(
'key' => '_um_last_login',
'compare' => 'EXISTS',
'type' => 'DATETIME',
),
'um_last_login' => array(
'key' => '_um_last_login',
'compare' => 'NOT EXISTS',
'type' => 'DATETIME',
),
),
'um_last_login' => array(
'key' => '_um_last_login',
'compare' => 'NOT EXISTS',
'type' => 'DATETIME',
array(
'relation' => 'OR',
array(
'key' => 'um_show_last_login',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'um_show_last_login',
'value' => 'a:1:{i:0;s:2:"no";}',
'compare' => '!=',
),
),
);
unset( $this->query_args['order'] );
+1
View File
@@ -180,6 +180,7 @@ IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSI
* Fixed: YouTube validation when field value is empty
* Fixed: Social URLs sanitizing where user can put his social username (e.g. Instagram, Facebook)
* Fixed: Using only published forms and member directories IDs on predefined pages installation
* Fixed: Member Directory before query hook when custom meta table is active
= 2.8.5 2024-04-09 =