How can I use the logged in user's group ID as a contextual filter in Views? I have Views, Context and OG installed on Drupal 7.

One of the default views is OG User Groups (/user-groups.) It is a content view that shows the user which groups they belong to.

I'm trying to create something similar, as a block (and therefore cannot use URL arguments.) I want a user view that shows all of the users from the logged in user's group.

In Views, it would make sense that I get the user ID from the logged in user as a contextual filter and then perhaps pass it as an entity ID (etid) to get the group ID (gid). But no matter what I do I cannot make a view that allows this to happen.

Does anyone know I can get the group ID from the current logged in user to use in this view?

http://i.stack.imgur.com/xU2zi.png
Once you enable OG Context, that comes with Organic Groups module, you can clone the og_members view since it does almost what you want: it shows members from one group. 

The OG Context module allows the "OG membership: Group gid" contextual filter to have a default value set to "Current OG Group from context". Nice, but we need members from all of the current use groups. So change the default value to "User ID from logged in user" to pass in the current user as the default argument. Then check the "Specify validation criteria" checkbox and choose PHP Code.

// let's see if there is a logged in user
if ($argument) {
  // og_get_entity_groups() returns the logged in user groups
  $groups = og_get_entity_groups();
  // setting $handler-&gt;argument changes the argument value 
  $handler-&gt;argument = implode('+', $groups);
  // you have to return TRUE, else nothing works
  return TRUE;
}
// this will run if $argument is 0, for anonymous users
else return FALSE;


The "Action to take if filter value does not validate" should be "hide view": no block is shown if there is no logged in user. Expanding the "More" fieldset should be a "Allow multiple values" checkbox. Check it: that's why we imploded the groups array in the argument validation — this way we can pass several groups as arguments.