这是我的代码,但没有得到想要的结果。我只想通过它的first_name和它的角色it_guy来搜索特定的用户。任何人都请帮忙。
$users = new WP_User_Query(
array(
'role' => 'it_guy',
'meta_key' => 'first_name',
'search' => '*'.esc_attr( $your_search_string ).'*',
'orderby' => 'first_name',
'order' => 'ASC',
'offset' => '',
'number' => '',
));
foreach($users as $user)
{
<?php echo $user->first_name; ?>
}
你应该试试这个,
$users = new WP_User_Query(
array(
'role' => 'it_guy',
'meta_key' => 'first_name',
'orderby' => 'meta_value',
'order' => 'ASC',
'offset' => '',
'number' => '',
'meta_query' => array(
array(
'key' => 'first_name',
'value' => esc_attr( $your_search_string ),
'compare' => 'LIKE'
)
)
)
);