How do I make the nodes referenced by organic group content also be OG content? I have an organic group called 'newsletter'.
I have two content types - 'issue' and 'article' - in 'issue' (which is set to be a group content type), there is a node reference field to articles, and many articles in a single issue, using an inline entity reference form.

I want to put an issue inside an organic group, for access control. I also want the articles that the issue references inherit that group content relationship without having to explicitly set the group for every single piece of content.

The group is public, but the content is private. I don't want anyone to access group content until they go though a process and purchase access via the commerce_licence_og module.

The article (content referenced in entity reference field) isn't added to the group content, though the issue itself is. I felt that a group reference for every article is redundant, and I would rather the article inherit the issue's access and status as group content rather than have a bunch of redundant fields and is automatic, not requiring additional admin steps. 

Is there an easy way to do this?
Do I HAVE TO make the articles group content in the UI?
Here is the solution I've come up with. 

It works, but might not be the most elegant solution. I didn't think that this would matter too much, since it's only being called on node save, but I'm open for comments and suggestions.

/**
 * Ensure that referenced nodes belong to the same organic group
 * 
 */
function MODULE_node_presave($node) {

  if ($node-&gt;type == NODE_TYPE) {

    $og = og_get_entity_groups('node', $node);
    $nids = get_referenced_nodes($node);

    foreach($nids as $nid){

      $child_node = node_load($nid);

      //Set the values
      $values = array(
        'entity_type' =&gt; 'node',
        'entity' =&gt; $child_node,
        'state' =&gt; OG_STATE_ACTIVE,
      );  

      //Add this node to the group
      $gid = array_values($og['node']);
      $result = og_group('node', $gid[0], $values);

    }    
  }
}


/**
 * Helper function - get all node reference fields of a node
 * @param $master_nid - the node id of the referencing node
 */ 
function get_referenced_nodes($master_node) {

  $fields = field_info_instances('node', $master_node-&gt;type);

  $items = array();

  foreach($fields as $field){

    if($field['widget']['module'] == 'inline_entity_form'){
      // Get the node reference items for this field
      $items[] = field_get_items('node', $master_node, $field['field_name']);

    }

  }

  // Loop through and grab the nids
  foreach ($items as $field) {
    foreach($field as $target){
      $nids[] = $target['target_id'];
    }
  }

  return $nids;

}