1

I can't get meta_queries working correctly on get_users(). For the life of me can't figure out what I'm doing wrong.

    $args = array(
        'meta_query'   =>

            array(
                'relation' => 'AND',

            array(
                'key' => 'minbeds',
                'value' => $rooms,
                'compare' => "<=",
                'type' => 'numeric'
            ),
            array(
                'key' => 'maxbeds',
                'value' =>  $rooms,
                'compare' => "=>",
                'type' => 'numeric'
            )
           array(
                'key' => 'minprice',
                'value' => $price,
                'compare' => "<=",
                'type' => 'numeric'
            ),
            array(
                'key' => 'maxprice',
                'value' => $price,
                'compare' => "=>",
                'type' => 'numeric'
            )
         )
    );

    $users = get_users( $args );
3

meta_query parameter is an array of arrays,

    $args = array(
        'meta_query'=>

         array(

            array(

                'relation' => 'AND',

            array(
                'key' => 'minbeds',
                'value' => $rooms,
                'compare' => "<=",
                'type' => 'numeric'
            ),

            array(
                'key' => 'maxbeds',
                'value' =>  $rooms,
                'compare' => ">=",
                'type' => 'numeric'
            ),

           array(
                'key' => 'minprice',
                'value' => $price,
                'compare' => "<=",
                'type' => 'numeric'
            ),

            array(
                'key' => 'maxprice',
                'value' => $price,
                'compare' => ">=",
                'type' => 'numeric'
            )
          )
       )
    );

    $users = get_users( $args );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.