I am not expert on php and need some help about custom query on my wordpress author page.
I have no problem when using WP_User_Query, the problem is i need to combine it with $curauth
What i need to do is get related authors list with WP_User_Query that filtered with current author page as a custom field value.
here is code that got error:
// WP_User_Query arguments
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
$label = echo $curauth->user_login;
$args = array (
'role' => 'contibutor',
'number' => '10',
'order' => 'ASC',
'orderby' => 'display_name',
'meta_query' => array(
array(
'key' => 'user_label',
'value' => $label,
),
),
);
// The User Query
$user_query = new WP_User_Query( $args );
// The User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
// do something
}
} else {
// no users found
}
I hope someone here can help to resolve my problem. Thank you