Custom contextual filter on views using Group module in Drupal I need to add a custom contextual filter in my view for the logged in user who is also a member of a Group specified in field_groups of my node. field_group is an entity reference field referencing group entity provided by the https://www.drupal.org/project/group module.

What is the simplest way of doing it? I am open to suggestions.
I did not found anything about view filters for the group module. You can only list group entities, not nodes from a group.

Looks like there some support for Panels but I don't know the module that much.

So I took the time to write some code, I just finished testing it. 

Just change yourmodule and your_view_id with the correct data and your view should only display nodes attached to groups from the current user:

/**
 * Implements hook_views_query_alter().
 */
function yourmodule_views_query_alter(&amp;$view, &amp;$query) {
  if ($view-&gt;name == 'your_view_id') {
    global $user;

    // Get current user groups.
    $groups = group_membership_load_by_user($user-&gt;uid);
    $groups = array_keys($groups);

    // Add join to filter on group ID.
    $join = new views_join;
    $join-&gt;construct(
      'group_entity',
      'node',
      'nid',
      'entity_id',
      array(array(
        'table' =&gt; 'group_entity',
        'field' =&gt; 'gid',
        'value' =&gt; $groups,
      )),
      'inner'
    );

    $query-&gt;add_relationship('group_entity', $join, 'node');
  }
}