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
+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'] );