Get user ids of group members I want to get a list of all users that are members of a group.
I can get the members using getMembers():
$members = $group-&gt;getMembers();
  foreach ($members as $member) {    
    var_dump($member);
  }

But this returns not User objects but GroupMembership objects:
object(Drupal\group\GroupMembership)#2609 (1) {
  [&quot;groupContent&quot;:protected]=&gt;
  object(Drupal\group\Entity\GroupContent)#2667 (28) {
    [&quot;values&quot;:protected]=&gt;
    array(12) {
      [&quot;id&quot;]=&gt;
      array(1) {
        [&quot;x-default&quot;]=&gt;
        string(1) &quot;1&quot;
      }
      [&quot;type&quot;]=&gt;

So how do I get the User IDs from the GroupMembership objects? Or is there an easier way?
Found the answer myself minutes after posting the question... so it goes :).
  $members = $group-&gt;getMembers();
  foreach ($members as $member) {
    $user = $member-&gt;getUser();
    $userids[] = $user-&gt;id();
  }