Hi Amitai,

The following OG exception

OgException: There are no OG fields in entity <em class="placeholder">user</em> and bundle <em class="placeholder">user</em> referencing <em class="placeholder">node</em> - <em class="placeholder">club</em>. in og_group() (line 2005 di ../og/og.module).

is triggered when a user try to create a SECOND GROUP in a configuration where only and only one group per user can be created/joined (configuration obtained setting cardinality = 1 for group_group and og_user_group_ref fields)

No exception are triggered if user is creating is FIRST GROUP.

Also I think that the link node/add/group should not appear at all if a user has already created his first (and unique) group.

Thank you for working on this

MXT

Comments

MXT’s picture

Issue summary: View changes
held69’s picture

Received this error after creating an og node as user #1

The field admin/config/people/accounts/fields/field_group_membership

are set to unlimited as well as on
admin/structure/types/manage/group/fields/group_group

The error dissapeared after removing the group membership field (mentioned above) and adding it back on.
however then seeing:
Notice: Undefined index: entity keys in entity_extract_ids() (line 7715 of C:\wamp\www\mysite\includes\common.inc).

https://drupal.org/node/2180165

NancyDru’s picture

I too am seeing this error now. OgException: There are no OG fields in entity <em class="placeholder">node</em> and bundle <em class="placeholder">portal</em> referencing <em class="placeholder">node</em> - <em class="placeholder">resource_team</em>. in og_group() (line 2017 of /modules/contrib/og/og.module).

This started when we added a second group type and went back and restricted this node to only the original group type.

NancyDru’s picture

I can set the field to unlimited and it works. But if I set it to 1, it does not. This is even after deleting the field (og_group_ref) and re-adding it.

jukka792’s picture

I am also seeing this "OgException: There are no OG fields in entity..." with OG 7.x-2.7.
But running cron between the deletion and creation of a new group helps. Or increasing the value "group membership" on this page: admin/config/people/accounts/fields/og_user_node

Also I have this setting selected in the "OG settings"
"Use the core's queue process to operations such as deleting memberships when groups are deleted."

Case 1:
When the value in the "group memebership" is "1" on this page: admin/config/people/accounts/fields/og_user_node

1. Create group
2. Delete group
3. Create new group
4. = OgException: There are no OG fields in entity...

(run cron)

1. Create group
2. Delete group
2.1 Run Cron
3. Create new group
4. NO ERRORS

Case 2:
When the value in the "group memebership" is "2" on this page: admin/config/people/accounts/fields/og_user_node

1. Create group
2. Delete group
3. Create new group
4. NO ERRORS
(but repeting the above steps comes again "OgException: There are no OG fields in entity..." )

So how to limit members to belong only to 1 group at a time but group administrators create and delete groups.
I am not sure, but maybe this setting has something to do with the error: "Use the core's queue process to operations such as deleting memberships when groups are deleted."

NancyDru’s picture

I am not using that setting. I am also not deleting groups. But I did fail to mention that the content I am trying to create is itself a group which also belongs to another group.

gunwald’s picture

I have the same problem. Actually I am using the code

/**
 * Implements hook_node_update().
 */
function custom_misc_node_update($node) {

  $gid = isset($node->field_project['und'][0]['target_id']) ? $node->field_project['und'][0]['target_id']: 0;  
  
  // Node type with group reference field.
  if ($node->type != "group_content" || !$gid) {
    return false;
  }

  $values = array(
    'entity_type' => 'node',
    'entity' => $node,
    'state' => OG_STATE_ACTIVE,
  );
 
  // Add this node to the group.
  $result = og_group('node', $gid, $values);
}

to add a node to a group programmaticall. This node type definitely has the groupref field .

darrenwh’s picture

Adding related ticket

darrenwh’s picture

joelpittet’s picture

Title: OgException: There are no OG fields in entity <em class="placeholder">user</em> and bundle <em class="placeholder">user</em> referencing <em class="placeholder">node</em> - <em class="placeholder">club</em>. in og_group() (line 2005 di ../og/og.module). » OgException: There are no OG fields in entity *user* and bundle *user* referencing *node* - *club*. in og_group() (line 2005 di ../og/og.module).

Fixing title