I've installed the latest 2.x-dev version. I have a test site with multiple groups defined. A new user can click on the "/group/node/%/subscribe/og_user_node" link in one of these groups and they are presented with the subscription confirmation form, and they are added to the group in a 'Pending" state. They can submit subscription requests as they want to different groups and things work as expected.

However, as soon as they become an active member in any group, the next time the click on the "Request group membership" link in any other group, they get a page not found error.

I have traced the cause of this problem to the og_ui_subscribe function in the og_ui/og_ui.pages.inc file.

The attached patch fixes the problem.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RoySegall’s picture

Are you sure you able to reproduce this on a clean installation OG? I created two groups, logged in as a regular user asked to subscribe on group 1, as admin i approve the request and then as the regular user request to join group 2 but i didn't get any page not found.

NofarG’s picture

Assigned: Unassigned » NofarG
Status: Active » Postponed (maintainer needs more info)

@ttaylor249
Regardless of the bug, which I couldn't reproduce either as @RoySegall said, your patch itself is wrong and I will explain why.
The function og_ui_subscribe() attempts to make the logged-in user a group content of a certain group, which means the group audience field is in the user entity.
The purpose of field_access() here is making sure that the logged-in user has access to the group audience field, which means in field_access() the $entity should be the logged-in user object, because that is where the group audience field is. Notice that in field_access() the $account defaults to the logged-in user, so there is no need to pass it as the $account as you did.

About the bug you reported - @RoySegall and I were not able to reproduce it on a clean environment, so your environment might not be clean. Instead of using an existing test site try installing drupal from scratch and just download and enable OG modules without any other contributed modules, and see if you still get the bug. If you do get the bug, please provide exact steps to reproduce so we can solve it.

ttaylor249’s picture

Component: og-ui » og-field-access

I was not using a clean install, so I created a new site with the standard installation profile. I was able to create similar behaviour to what I described above.

Following these steps, things worked like I expected:
1. Enabled the organic groups, organic groups access control, and organic groups ui modules and their dependencies.
2. Created a new content type and made it a group, then created three instances of that group type.
3. Created a regular user and logged in, visited one of the groups and requested membership.
4. As the admin, I made the user an active member of the group.
After these steps, the user was still able to request membership to other groups. I then unsubscribed from all the groups.

5. As admin, I then enabled the Organic groups fields access module.
6. As admin, went to admin/config/group/permissions/node/ and enabled the following permissions in the "Organic groups field access" section:
a) View Group field: all roles
b) View Body field: all roles
7. As regular user, visited one of the groups and requested membership.
8. While status is Pending, the user can also request membership in other groups.
9. As admin, change users status to active in one of the groups.
10. As regular user, visit a group where membership hasn't been requested. There is now no link to request membership. If you manually try to go to group/node//subscribe/og_user_node you get the "page not found" error.

ttaylor249’s picture

Actually, I think I just figured out the problem...

I needed to enable the "view Group membership field" for the Member role. Once I did that, the regular user could request membership in new groups, even after they were made an active member of another group.

Why is this permission not required before the user is a member of a group?

NofarG’s picture

Status: Postponed (maintainer needs more info) » Active

Following the steps you provided I am now able to reproduce this bug and enabling "view Group membership field" does solve it although it was not needed at first. I'm on it.

NofarG’s picture

Removed permissions to view and edit audience fields, this permission should never be blocked.
Here's a patch.

NofarG’s picture

Status: Active » Needs review

Changing status to "Needs review".

amitaibu’s picture

@ttaylor249 please confirm this is working for you.

amitaibu’s picture

Nofar please confirm the patch is working fine, you told me you saw some WSOD related to it?

NofarG’s picture

@Amitaibu The patch looks good on a clean installation, I was not able to reproduce it again (BTW it wasn't WSOD, it was a missing field). So the error must have been because of something else, not the patch.

ttaylor249’s picture

@Amitaibu The patch in #6 does indeed fix the problem I was seeing. Thanks.

johnennew’s picture

Status: Needs review » Reviewed & tested by the community

I have a site which was experiencing this exact problem. I confirm the patch in #6 fixes the issue.

Thanks

charles1988’s picture

Same issue. #4 fixed it. Give the permission to 'member'

odizle’s picture

Had the same issue, #6 patch worked for me.