Home › Forums › General Issues › Filter User Query › Reply To: Filter User Query
Hi, still totally lost on this.
I have updated the query to look like this:
<?php
$args = array(
'meta_query' => array(
'relation' => 'AND',
array(
'meta_key' => 'department',
'meta_value' => 'Social Work',
'meta_compare' => '=',
),
array(
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC',
'exclude' => array(1,8,9),
),
)
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
um_fetch_user( $user->id );
?>
So the way I read this is that it should be looking for users that have “SOCIAL WORK” checked off in the “DEPARTMENT” ACF field that I created….(its a checkbox field).
AND, it should then look at the USER LAST NAME, and ORDER those in ASC order.
However when I do this code, I still get tons of users listed linked to all kinds of departments, not just ones that include SOCIAL WORK as I want.
Please help!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.