diff --git a/includes/class-user-query.php b/includes/class-user-query.php index e0f47bec..641fa988 100644 --- a/includes/class-user-query.php +++ b/includes/class-user-query.php @@ -112,23 +112,36 @@ public function add_virtual_subscriptions( $args = array() ) { if ( isset( $args['meta_key'] ) && substr( $args['meta_key'], -9 ) === '_starred' ) { $args['meta_key'] = 'starred'; } + $searches = array(); + if ( isset( $args['search'] ) ) { - $args['search'] = str_replace( '*', '', $args['search'] ); + // WP_Term_Query will add wildcarts before and after. + $args['search'] = trim( $args['search'], '*' ); + $searches[] = $args; + $searches[] = array( + 'meta_key' => 'display_name', + 'meta_value' => $args['search'], + 'meta_compare' => 'LIKE', + ); + } else { + $searches[] = $args; } - $term_query = new \WP_Term_Query( - array_merge( - array( - 'taxonomy' => Subscription::TAXONOMY, - 'hide_empty' => false, - ), - $args - ) - ); + foreach ( $searches as $args ) { + $term_query = new \WP_Term_Query( + array_merge( + array( + 'taxonomy' => Subscription::TAXONOMY, + 'hide_empty' => false, + ), + $args + ) + ); - foreach ( $term_query->get_terms() as $term ) { - $this->results[] = new Subscription( $term ); - $this->total_users += 1; + foreach ( $term_query->get_terms() as $term ) { + $this->results[] = new Subscription( $term ); + $this->total_users += 1; + } } } public function sort( $field, $direction ) {