WordPress WP_User_Query ignores the `meta_query` when called from an Ajax functi
-
I have an ajax function that runs the following
WP_User_Query
:$args2 = array( 'meta_query' => array( 'gender' => array( 'key' => 'gender', 'value' => 'female', 'compare' => '=' ) ), 'number' => 10 ); $user_query = new WP_User_Query( $args2 );
The query is returning unfiltered results, basically ignoring the
meta_query
. It works fine if I run it fromfunctions.php
or from a template file, but not fromajax
. Any idea why?This is the?
request
?string when it works:SELECT SQL_CALC_FOUND_ROWS wp_users.ID FROM wp_users INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id ) WHERE 1=1 AND ( ( wp_usermeta.meta_key = 'gender' AND wp_usermeta.meta_value = 'female' ) ) ORDER BY user_login ASC LIMIT 0, 10
And this is the one from the ajax function:
SELECT SQL_CALC_FOUND_ROWS wp_users.ID FROM wp_users WHERE 1=1 ORDER BY user_login ASC LIMIT 0, 10
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘WordPress WP_User_Query ignores the `meta_query` when called from an Ajax functi’ is closed to new replies.