After fishing around the issue queue, I found someone with the opposite problem - https://drupal.org/node/1784118

As user 1, I can add group content nodes without assigning them to a group. Other admins on the site can't add group content nodes without first selecting a group. The group audience field is not set to be required.

Help please!!

Comments

idcm’s picture

Issue summary: View changes
idcm’s picture

Update. When I disable the og_access module and uninstall it, this issue goes away.

Also, when og_access was enabled, a couple other things went wrong.

1. the "request membership" link disappeared from the og view listing groups
2. the body teaser disappeared from the og view listing groups
3. all the fields except for title disappeared when trying to create a group content node

thoughts? I really need og_access to work.

shushu’s picture

Status: Active » Postponed (maintainer needs more info)

Regarding to your first issue, I thinkg this will give you an answer.

Regarding to all of those issues in your second comment, I believe it is all about configuration, and will disappear once you setup your site as needed.

idcm’s picture

The solution - if you want a user to be able to create site-wide content - you must give him permission to do so. Otherwise, he will be able to create the content only inside the group.

Interesting. {correction: og access was not enabled for this test} Switched to one of my test users. It could create the content with connecting it to a group.

I switched to the user who reported the issue. She is a full admin. She gets "You must select one or more groups for this content."

I switched to another admin and it worked.

I am an admin but in as user 1 and I can do it.

Hmmm. She's a group admin but so am I. So is the tester of a lower role. Thoughts?

idcm’s picture

Okay. So redid the test with the odd admin user and og access didn't have anything to do with the issue.

The following issues have been tested again with og access turned back on.

1. the "request membership" link disappeared from the og view listing groups - it's back

2. the body teaser disappeared from the og view listing groups - it's there

3. all the fields except for title disappeared when trying to create a group content node - they are back

Gremlins!! That's the only way to explain it. Next ... continue testing if private works now that the weird stuff has stopped.

idcm’s picture

With og access on, I did the following to turn groups private. Please let me know what I am missing.

1. go to admin/config/group/fields, selected the group bundle (as that is the group node).
2. select group visibility field
3. clicked add field
4. went to admin/structure/types/manage/group/fields and confirmed that the field was there. default setting is public
5. added a group and set it to private
6. confirmed that I can see it the list of groups
7. switched to a non member, lower role test user
8. test user can see the private group in the list of groups
9. clicked on the group and was granted access
10. switched back to admin and looked at devel node access block. All users in the list have view access. -- [update- the test user showed YES: {node_access} in the devel node access block] to me that says og access isn't engaged ... right?

What am i doing wrong?

idcm’s picture

I just realized the topic has changed. Do you want to move this to a new issue?

idcm’s picture

I just got some great help from asghar solving the private access issue.

For anyone else having this issue, let me explain what was happening.

I have content access installed and og access and content access was winning out over og access. So ... asghar went to admin/structure/types/manage/group/access (group is the name of the group node) and opened the advanced setting open at the bottom of the screen.

He set it to -10 (not sure if that is the magic number) but it worked.

In the end, regular authenticated users can't see groups but authenticated+the scholar role can see public groups but not private groups.

So .. my process in comment #6 above was correct, it was the conflict with content access that was the problem.

Thanks again to ashgar for his help

shushu’s picture

@idcm good to hear you find the solution.
Would you consider adding some documentation or blog post about your use case ?

nbennett_tag’s picture

I had this issue recently as well - the node edit form was throwing the 'You must select one or more groups for this content.' error even if the Required setting on the OG Groups Audience field wasn't set. The og_form_group_reference_validate() function is being added to the form['#validate'] array regardless of the 'Required' setting on the field. I was able to do a hook_form_alter on the node edit page to unset the widget validation if the field wasn't required:

function custommodule_form_alter(&$form, &$form_state, $form_id) {
  $field = field_info_instance('node', 'og_group_ref', [NODE_TYPE]);
  // If it is required, don't unset the validator.
  if ($field['required']) {
    return;
  }
  
  foreach ($form['#validate'] as $index => $method) {
    if ($method == 'og_form_group_reference_validate') {
      unset($form['#validate'][$index]);
    }
  }
}
tomyinhauser’s picture

@nbennett_tag, I think you missed the point here. As @shushu commented on a related post, this validation isn't about simple required field validation, but to ensure that "group-only content permissions are honored".

But I think this call from the og_form_group_reference_validate to node_node_access() is indirectly preventing other node access modules to be applied. In my case, I have removed the create/update node permissions from editors, because I have both domain module, which gives more granular access according to the assigned domains, and a custom module which gives node access to a specific kind of user when some custom business rules apply.

Isn't it possibe to check this condition otherwise, to keep OG working with other node access modules?

kayograco’s picture

Cindy, I went to admin/people/permissions, checked the permissions to create content for the specific content type for the role causing trouble, and done. The error is gone.

spesic’s picture

@kayograco, right on the money. Bypass content access control by itself won't do the trick. Adding permissions for admin level role to create the particular content type did the trick.

jastraat’s picture

@nbennett_tag
Your code was extremely helpful. There is currently an issue when a node is both a group and group content which I do believe is a bug.

If the audience field of the group is optional, group admins of the group (even when they have the 'update group' permission) cannot edit a group because the node form still uses the optional audience field for validation - ignoring the group permissions of the group node being edited. I used an adaptation of your code to get around this in the case that a user had the OG 'update group' permission.

asiby’s picture

#12 and #13 did the trick for me. I will rephrase what @spesic and others have said before ... we shouldn't hack our way through what seems like a solution when only one module seems to break Drupal's logic. This is like having a firefighter's mindset that will make him break your house's door with an ax instead of trying to use the door knob or checking if anyone in the house can open the door for them.

Cheers