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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
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.