get_users meta_query

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 );

Related posts

Leave a Reply

1 comment

  1. 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 );