Home › Forums › General Issues › Filter User Query › Reply To: Filter User Query
Hi @juiceex
You need to put the ‘meta_key’, ‘orderby’, ‘order’, and ‘exclude’ options outside of the ‘meta_query’ option like this:
<?php
$args = array(
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC',
'exclude' => array(1,8,9),
'meta_query' => array(
'relation' => 'AND',
array(
'meta_key' => 'text',
'meta_value' => 'check1',
'meta_compare' => '=',
),
)
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
print_r( $user );
}
}
?>
Please check the example on the bottom of the page I gave you before.
Hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.