Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

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.