og icon indicating copy to clipboard operation
og copied to clipboard

non-required group audience field failing validation when group admin edits group node

Open bradbulger opened this issue 10 years ago • 1 comments

We have a content type that can be a group and sometimes group content as well. (eg node 123, "My Group", is itself an OG group node, and belongs to the OG group 456, "My SuperGroup") most nodes are only group nodes, and are not members of any other group. the og_group_ref group audience field is not required.

however, group admins - people who are members of the group with the "administrator member" group role - are unable to save changes to the group node, even though they have the OG permissions "Edit group" and "Administer group", because when they don't choose an existing group in the group audience field (either leaving it altogether blank, or selecting "- None -"), they get the error, "You must select one or more groups for this content."

users who have Drupal role based edit permission on the content type do not get this error. giving the group admins explicit OG permissions on the og_group_ref field makes no difference.

there are other issues related to this validation error in the Drupal issue queue, but they all boil down to different problems, from what i can see.

bradbulger avatar Feb 03 '15 16:02 bradbulger

It seems to make sense to me add these lines to the og_form_group_reference_validate() function:

if (og_is_group($entity_type, $entity) && og_user_access($entity_type, $id, 'edit group', $account)) {
  // Entity is a group and user has permission to edit the group.
  return;
}

bradbulger avatar Feb 03 '15 16:02 bradbulger