I have this code and it works fine but it is not sorted.
$args = array(
'meta_key' => 'pw_user_status',
'meta_value' => 'approved',
);
$users = get_users( $args );
I tried to sort the results using the below with no success...
$args = array(
'meta_query' => array(
array(
'key' => 'pw_user_status',
'value' => 'approved' ,
),
),
'orderby' => 'meta_value',
'meta_key' => 'user_lastname',
'order' => 'ASC'
);
$users = get_users( $args );
I have this code and it works fine but it is not sorted.
$args = array(
'meta_key' => 'pw_user_status',
'meta_value' => 'approved',
);
$users = get_users( $args );
I tried to sort the results using the below with no success...
$args = array(
'meta_query' => array(
array(
'key' => 'pw_user_status',
'value' => 'approved' ,
),
),
'orderby' => 'meta_value',
'meta_key' => 'user_lastname',
'order' => 'ASC'
);
$users = get_users( $args );
Share
Improve this question
edited Apr 27, 2019 at 18:51
G-J
asked Apr 27, 2019 at 18:42
G-JG-J
1014 bronze badges
1 Answer
Reset to default 0Should be 'meta_key' => 'last_name'
instead of 'meta_key' => 'user_lastname'
$args = array(
'meta_query' => array(
array(
'key' => 'pw_user_status',
'value' => 'approved' ,
),
),
'orderby' => 'meta_value',
'meta_key' => 'last_name',
'order' => 'ASC'
);
$users = get_users( $args );
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745545531a4632320.html
评论列表(0条)