WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 );
share|improve this question
up vote 1 down vote accepted

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 );
share|improve this answer
    
Perfect, thanks! – jamessy Jan 14 '13 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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