I want to list my users which are in wordpress according to their roles with json api.
Normally I use v2 api. x.com/wp-json/wp/v2/users?page=1&per_page=100
api doesn't return me user roles or I couldn't filter it. Like author or subscriber.
I wanted to write a different php file myself, where I can take the roles and read them, but the shortcoming here is that the user avatar does not come.
Here my custom php kodu.
$sql = "SELECT u.id,u.display_name,um.meta_value FROM wpuy_usermeta um inner JOIN wpuy_users u on u.ID = um.user_id WHERE meta_key = 'wpuy_capabilities' Order by u.display_name asc";
$result = $conn->query($sql);
$rows = array();
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$rows[] = $row;
}
print json_encode($rows);
} else {
echo "0 results";
}
$conn->close();
all I need is id user name, user role, user avatar. how can i solve this

