Friday, December 20, 2024
HomeWordPress Developmentwp question - Wordpress WP_User_Query ignores the `meta_query` when referred to as...

wp question – WordPress WP_User_Query ignores the `meta_query` when referred to as from an Ajax operate


I’ve an ajax operate that runs the next WP_User_Query:

        $args2 = array(
            'meta_query' => array(
                    'gender' => array(
                        'key'     => 'gender',
                        'worth'   => 'feminine',
                         'examine' => '='
                    )
                    ),
                    'quantity' => 10
         );
        $user_query = new WP_User_Query( $args2 );

The question is returning unfiltered outcomes, mainly ignoring the meta_query. It really works superb if I run it from features.php or from a template file, however not from ajax. Any concept why?

That is the request string when it really 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="feminine" )
                )
                ORDER BY user_login ASC
                LIMIT 0, 10

And that is the one from the ajax operate:

                SELECT SQL_CALC_FOUND_ROWS wp_users.ID
                FROM wp_users
                WHERE 1=1
                ORDER BY user_login ASC
                LIMIT 0, 10

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments