On a fresh install, I receive the error message "Can't save entity as group, because user admin can't be subscribed to group and become a manager" when trying to submit a test group with the og_example module "group" content type.

It's not immediately clear what the problem is there based on this text or the code comments, but this validation appears to have been introduced by #1490646: Prevent exception if user try to create group, withouht group audience.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ezra-g’s picture

Status: Active » Closed (cannot reproduce)

I can't reproduce on a new fresh install.

Illusioneer’s picture

Mine isn't a fresh install but I'm getting the same error when I tried to create a new entry on a brand new content type.

kenianbei’s picture

Steps to reproduce:

1) New drupal install
2) Enable all og modules (except migrate)
3) Rebuild perms
4) Add content type 'Group' and group_group field.
5) Create 2 users, give them create/edit/delete own perms for content type 'Group'.
6) User1 creates Group1, and adds User2 to Group1.
7) User2 attempts to add content type Group, but no go...

ezra-g’s picture

Status: Closed (cannot reproduce) » Active

Marking as active based on the reproduction steps.

amitaibu’s picture

This error is trying to prevent subscribing a member that reached their maximum allowed groups (i.e. the field cardinality of the group-audience attached to the user isn't unlimited). Is this the case for you guys?

kenianbei’s picture

In the steps I went through for setting up og, did I miss a step where I need to change the cardinality of the group_audience attached to the user? The only user field that seems possible is og_user_group_ref, but that is already set to unlimited.

The group node (with group_group field attached) doesn't have a group_audience field attached to it in my example above. I'm not sure what you mean by "field cardinality of the group-audience attached to the user"... Can you clarify?

shenzhuxi’s picture

I got the same problem after I uninstalled OG 7.x-1.4 and installed 7.x-2.x-dev.

ditcheva’s picture

Same here. I cannot create any new groups even though I'm admin (user 1) due to the message above.

amitaibu’s picture

Please answer question in #5

ditcheva’s picture

Like #6, I'm not entirely sure I understand the question.

However, I've gone to admin/config/people/accounts/fields and checked that the 'Groups audience - Node' field is set to 'Unlimited'.

Also, I'm the admin user (user 1), so I thought I ought to be able to create new groups regardless of how many groups other users can be a member of...

Either way, please let me know if I'm not answering the right question.

amitaibu’s picture

> However, I've gone to admin/config/people/accounts/fields and checked that the 'Groups audience - Node' field is set to 'Unlimited'.

Yes, you answered to the right question :) Seems like a bug.
Are you a developer -- can you debug it?
If not, is it a dev site you can attach a DB dump?

ditcheva’s picture

It looks like it's throwing this error in the og.module file, og_form_group_manager_validate() function because it cannot find a matching group_audience_field on my user account.

The validate function ends with the following lines

  if ($access = og_get_best_group_audience_field('user', $account, $entity_type, $bundle)) {
    // Matching group audience field found.
    return;
  }

  form_error($form, t("Can't save entity as group, because user @name can't be subscribed to group and become a manager.", array('@name' => format_username($account))));
}

The problem is... of course I don't have a matching group_audience_field.... I'm only trying to create the group now, so it doesn't exist. I may be misunderstanding the lines of code, but do you think that's the problem?

ditcheva’s picture

OK, it looks like the issue is that the default settings on the admin/config/people/accounts/fields/og_user_group_ref are a little off after you enable it. Mine had the 'target type' set as 'User' rather than 'Node'.

The language in the field descriptions can be hard to understand for somebody who isn't used to OGs (target type, target bundle, and entity selection mode), so I had left all of those as defaults at the beginning. However, I just solved my issue by playing around with them.

Hope this helps someone else!

jelo’s picture

I used 7.x-2.alpha3, uninstalled it, then installed beta1. Now I get the same error. In admin/config/people/accounts/fields the field 'Groups audience - Node' does simply not exist. Am I supposed to create it manually or should it have been created as part of the installation?

amitaibu’s picture

You can safely create it manually.

jelo’s picture

I have added the field and it seems to work. However, there seem to be more issues. The view OG User Groups (OG membership) is reporting "broken/missing handlers" in the relationships. I am concerned that there might be more incorrect settings or broken views. Any suggestion how to cleanly get rid of previous installs to start fresh with the latest version?

Thanks, J.

amitaibu’s picture

> The view OG User Groups (OG membership) is reporting "broken/missing handlers" in the relationships

Do you have a content type defined as group?

jelo’s picture

Yes, and after adding the Groups audience - Node field manually, I was actually able to sign up for a group. I just noticed that adding the field manually made 2 more OG fields (og_user_group_ref, og_other_user_group_ref) appear in the profile that were not there before. Hence, I eliminated the manually created field and now I seem to have the fields that should probably have been there in the first place.

The view still has a broken handler though...

kenianbei’s picture

I was able to resolve this issue by deleting 'Groups audience' field on user, using the OG field settings UI, and then re-adding the field. I'm still unclear exactly why the error message is occurring when following the steps I outlined above in #3.

chrisschaub’s picture

I have the same issue. What is the point of that code in the validate function? Also, should there be one field or two. At one point I had My Groups and Other Groups, now, after deleting and re-adding, I only have one.

Michsk’s picture

Field is not created on my setup either...

ataxia’s picture

This is causing major issues with a site that we are preparing to launch next week. It seems to be a new issue, since we have been allowing people to join Teams and create Teams without problems for months.

I have tried all of the suggestions (patch that failed, manually adding field) and nothing is working. This is getting critical!

current OG version: 7.x-2.0-beta1

Thanks!

amitaibu’s picture

Field is not created on my setup either...

Did you try to add it manually via the Group field settings page (admin/config/group/fields)?

ataxia’s picture

Yes. I just manually added the field and tried it again to be sure.

"Can't save entity as group, because user gcarmonayo can't be subscribed to group and become a manager."

Previously, users had fields for:

Group membership (og_user_group_ref)
and
Other groups (og_other_user_group_ref)

After manually adding the field, they now also have: Groups audience (og_group_ref)

In all fields, the number of values is unlimited. I left all settings in their default state.

Should "Enable Entity reference prepopulate" be selected? What else can I try?

Thanks!

Michsk’s picture

Just to let you guys know, my setup was completly messed up because of manuall deletes from tables etc and reinstalling etc etc. But not manually removed every OG reference i could find in mysql and reinstalled, everything is working as expected.

ataxia’s picture

Hi lasac -

Can you be more specific? Did you delete the OG reference fields from only user records or all records? Did you lose any data?

Thanks!

Michsk’s picture

I removed OG from every position i could find. Of course you will loose the data (except you do a backup). But this was the first time i was installing OG on that site. Before you do manual deletes you must backup.

ioskevich’s picture

Got this issue as well after updating from OG 7.x-2 Beta1 to 7.x-2 Beta2-dev.

Issue disappears once I disable OG Field Access module (shipped with OG). If OG Field Access is enabled, no matter what permissions I set, I am getting the error message from the subject.
However, it happens only when I try to create node which is supposed to be group content and is group itself.

ydahi’s picture

FileSize
28.7 KB

#13 worked for me.

admin/config/people/accounts/fields/og_user_node

Change "number of values" field to unlimited (or a specific amount other than 1 if you want users to be able to join multiple groups)

see screenshot attached.

royerd’s picture

Like some of the others, when I changed the field setting to "unlimited" at

admin/config/people/accounts/fields

it fixed the problem for me and the error message no longer appears.

keyiyek’s picture

Same problem here, can't resolve with the aboves.

keyiyek’s picture

I made a few tries on this, this is what I got.

I started with a clean installation
OG 7.2-rc4 (enabled field access, context and UI as well)

I created a content type that could be a group.
I created 2 users.

The admin creates a group. (fine)
User1 joins the group (fine)
User1 creates a group (fails!!!)
User2 creates a group (fine)
User2 joins a group (fine)
User2 creates a group (fine)
User1 unsuscribes from the group (fine)
User1 creates a group (fine!!!)
User1 joins a group (fine)
User1 creates a group (fine)

Seems that if an user that hasn't created a group, once she/he joins a group, she/he becomes unable to create more groups. An user that already has created a group can subscribe to a group without any further problem.

I hope this gives you some clue.

kefa007’s picture

Seems this issue has been around for quiet a while. I tired all the above - without any luck. I hit the issue on the site I was developing. Since it makes sense to see whether or not it is an issue I have introduced I run tests on 3 new and clean drupal installations. I hit the issue each time - will this be resolved or do I miss something. Cheers

TechNikh’s picture

I am seeing the same error.
I deleted all the existing content(groups & group content) but doesn't help.

lyosef’s picture

Have been struggling with this problem intermittantly for many months now. Barely advance on my project when the issue reappears; suddenly unable to create or edit a group. I have returned to this page many times seeking an answer. "Number of Values" at admin/config/people/accounts/fields/og_user_group_ref is set to unlimited. Will have to revert to a working backup AGAIN (losing many weeks of work AGAIN). Would be so grateful if someone would please share the real secret of making this work reliably. Suggestions? Patches?

lyosef’s picture

lyosef’s picture

ditcheva, could you share what you've learned by "playing around" with the OG settings. Maybe a screen shot? :)

laboratory.mike’s picture

Here was one issue I came across, and how I fixed it:

1) I somehow didn't have a group field for users at all (???), so I went to admin/config/group/fields and created a new field for the user bundle.
2) Like everyone else, I then went to admin/config/people/accounts/fields/ and set the field to be unlimited.

I'm nowhere close to being an OG expert, but I'm guessing that some people could be having issues at admin/config/group/fields besides the user field issue.

TechNikh’s picture

Got it at last. #13 worked for me.

I uninstalled "Organic groups register" module all it's related fields in the group as well as user entity.
re installed and made sure group has the register field & the user entity has the group_ref field

This is how I added group_ref field to user entity
on this page www.example.com/admin/config/group/fields
"Added field Groups audience (og_user_group_ref) to user."

drstuey’s picture

I'm getting this error when admin user attempts to create first group

This is a local install of D7.17 with OG 7.x-2.0

I am following the book Definitive Guide to Drupal 7 and so it is not a completely fresh install - I have installed, enabled, played around and then disabled a number of modules.

In the book they suggest enabling the OG example module to create the content type that will be the group. I did this so I have a Group content type with default settings.

I enabled all the modules that come with OG. I did get a couple of timeout errors reported when saving the module configuration, but all the checkboxes for all the modules appeared to have been checked when I returned to the module list so I assumed it was fine.

The book refers to "when you enable the OG access control module you will be prompted to rebuild your permissions" but I never saw such a prompt. So I haven't rebuilt my permissions - I did go to the permissions page and click save.

I don't have any OG fields in admin/config/people/accounts/fields which I suppose is the problem, but I don't know what to add to try and add them manually.

I tried disabling all the OG modules and then enabling them again.

Tried disabling the OG field access module as suggested by #28 but creation of group still fails.

Finally I manually created a field in admin/config/people/accounts/fields choosing Entity Reference, Organic Groups and Unlimited for all the relevant options and now it worked, I can now create a group.

sajosh’s picture

I 'fixed' it too. Not exactly sure how or what happened but I just played around with some things. I'll first tell you what I think did it. Then I'll tell you what else I tried.

Before I start, I should mention that my user 1 didn't have any problems saving as group. It was another test user. I have a clean install of D7.21, OG7.x-2.0, and others.

What I think solved it was following #13. Specifically setting admin/config/people/accounts/fields/og_user_node which is ... Group membership og_user_node Entity Reference OG reference. In there I put (or reselected when it was already this way) the following ... Target Type = Node, Entity Selection Mode = Organic groups, and Target Bundles to what's available, and OG membership Type to Defalut.

Then I edited the user that was not 'saving as group' and selected Group Membership to None. I saved the user.

Then I was able to successfully 'save as group' with a non-admin user.

But the other things I mess around with which might or might not have an influence were ... cleared cache, and rebuilt permissions, had admin create an initial group (which might have influenced the second group save by the non-admin user).

Hope this helps.

Leeteq’s picture

That's really great writeups from both of you in #40 and #41, @dstuey / @sajosh :-) - Thanks!

Sounds like there are some missing settings that should be set as defaults "out of the box" at the point of installation.
And that we need tests that can auto-fix this at any stage later, if an admin has made some configuration mistakes.

Mo Omar’s picture

I have been trying for days and I am still facing this problem. There are other problems as well with OG now and I am wondering whether I should move to an older version or find anther way that ignores this module entirely.

Here is what I found out:

1) If a user has been subscribed to a group first then tried to created another group, he will get the error that he can not be a group manager therefore, he can not create a new group.

2) If the same user has not subscribed to a group first or he manually unsubscribed himself from that first group and tried to create a new group, no problem. at this point he can create new groups and subscribe to other groups as many as he wants.

3) I also found out that permissions are not working correctly and I faced so many issues with trying to configure them. Here are some permissions issues I faced with a clean drupal install:

  • When a user adds new OG content, he can see the title and the group audience fields but unable to see the body fields therefore he can not create new OG content
  • I face even more issues if I choose to uncheck the box Group manager full permissions in admin/config/group/settings. User is unable to edit the group even if I gave him the permission to edit the group in the admin/config/group/permissions/node/private_group
  • On one of my drupal test fresh installs, the admin, myself, couldnot edit the group from the group node because the group tab was inactive.
  • If I wanted to create a private group with no choice for the user to edit the privacy settings, I must install field permissions module to hide the privacy permission. OG access module does not work with OG admin even if I unchecked the box on the group permissions page related to view and edit the privacy field.

4) I get error with devel module if I tried to create OG content. See: http://drupal.org/node/1986438

Unfortunately, I am not a coder but I can further explain any of my points if this can help.

rsvelko’s picture

#5 is correct - at least for me.

In my case I have a og_user_node - og ref field that can have only 1 value ... so trying to create a second group would make you the manager of it and thus you now will be in 2 groups - but the field can have 1 ref....

TMP solution:

raise the field settings to 4-5 or 10....

admin/config/people/accounts/fields/og_user_node

- create the group
- and switch it back to 1

Other than that - we need a global site permission : "allow to create groups whatever" or "administer OG" or sth like that - that will be meant for super admins...

rsvelko’s picture

... if that perm already exists - patch the code around og/og.module:800 to use the perm and not fire the error validation...

sparker888’s picture

Just ran into this problem myself. Neither the admin (user 1) nor assigned 'Group Manager' role with permissions to create and administer groups and group content can create group entities. This is a huge wall for our entire project. Any further progress as I've noticed 30 people are subscribed to this issue and no activity for three weeks? Thanks!

Edit: The workaround of deleting and re-creating (all) the OG Reference Fields seems to have solved the immediate problem of creating group entities. Still exploring whether there are now extenuating issues. Note that this issue occurred for us after upgrading to 7.x-2.x as well.

Tresler’s picture

The issue behind all of this is that this is a badly written validation function.

It checks to see if one of X scenarios passes, and defaults to failing with a vague error, as opposed to checking to see if it has a valid field value or throwing a specific error if it doesn't. To take that logic further, it is checking that config options are set properly when submitting a node, that is insane.

I'll rewrite and submit a patch once I figure out what it is actually trying to validate.

If #5 is accurate, "This error is trying to prevent subscribing a member that reached their maximum allowed groups (i.e. the field cardinality of the group-audience attached to the user isn't unlimited). Is this the case for you guys?" it should just be checking if the user has exceeded their allowed groups and informing them that they have and how many they are allowed.

However, with the number of checks there, that can't be *all* it does. Input welcome.

amitaibu’s picture

I'll rewrite and submit a patch once I figure out what it is actually trying to validate.
...

it should just be checking if the user has exceeded their allowed groups and informing them that they have and how many they are allowed.

Great, it would be nice to get a patch that would add the info to the validation error.

ajjkoch’s picture

Hallo together,

I have this Issue two and it blocks our whole site.

I even tried to remove the error message from the validation hook. But then it runs into an internal error so the validation can't be for nothing. What me bothers most I have no clue way this happens.

I also tried to disable the Organic groups access control and to add entity reference fields and other stuff that is written above. Nothing help until now.

So, please, can someone of the og responsible help and write a patch or give a solution?

Otherwise it spoils the whole thing.

I really need help to get this run.

greetings, Achim.

evilehk’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
928 bytes

I received this error and found that an orphan entry an og_membership not yet cleaned up by cron will cause it. Here is how to recreate the error on a clean install:

1) enable og, og_field_access, and og_example (for the Group content type).
2) In OG settings (admin/config/group/setting), uncheck the "Group manager full permissions" checkbox. The "Strict node access permissions" remains enabled.
3) I have Use queue and Delete orphans enabled, but it is not necessary to recreate the error message.
4) Go to permissions (admin/people/permissions) and make sure authenticated users can create and edit the Group node type
5) Create an authenticated user, and log in with the new user
6) New user creates group content, it is successful
7) Delete the group content
8) New user creates group content again, receives "Can't save entity as group, because user @name can't be subscribed to group and become a manager." error message

The attached patch resolves the issue by verifying og context exists before returning FALSE in og_user_access_entity

jhedstrom’s picture

The patch in #50 doesn't seem to resolve the issue. I'm seeing this on a site that requires single-group-membership for users, but where a single administrator will create all the groups. Setting author to anonymous is a temporary workaround in this specific case.

Leeteq’s picture

Priority: Normal » Major
evilehk’s picture

Thanks for the feedback, jhedstrom (and for all your countless drupal contributions!). In my particular situation, the OG group manager default role validation function (og_form_group_manager_validate) was trying to determine access to the "best" group audience field - which it determined to be the og_user_node field of the user object. This eventually kicks off hook_field_access. With OG Field Access enabled og_field_access_field_access is ran and it contains the logic that if the group being saved is new (a non-saved entity), to check all the other groups of the user to determine access to the og_user_node field.

The patch accounts for the situation where it finds a group in og_membership but that group has been deleted. As a result, it returns FALSE when it really should return nothing. Is it possible that the single administrator doesn't actually have view access to to og_user_node in some of its groups? The OG permissions overview page is at admin/config/group/permissions.

Perhaps the real solution is not in og, but in og_field_access in implementing another way to check for field access in a non-saved entity create form.

xanderol’s picture

I'm having the same problem. Also tried the above solutions with no luck.

The only way I can prevent the error is to go to OG permissions overview and grant the “Administer group” permission to the administrator member or disable organic group field access module.

Unfortunately I don't want users to have full administration rights to the group. And I do want to restrict access to certain fields.

So it seems that if I don't want to grant the Administer group permission I have to disable the field access module.

evilehk’s picture

I'm curious to know for anyone who installed the patch from #50 and it didn't work for them if 1) OG Permissions has enabled view access for og_user_node for the role of the user experiencing the issue, and 2) if the module FAPE is installed.

bramface’s picture

I'm confused about the difference between user fields og_user_node and og_group_ref.

I think og_user_node is unnecessary at this point and am considering deleting it, except for the error on this page that seems to require it.

Can anyone explain the difference between these two fields? I'm thinking that one has to do with membership, and the other has to do with visibility via OG field permissions....

namita21’s picture

I tried #50 patch but it didn't work for me.
Still getting same error and not allowing to create a group.

namita21’s picture

OK I got my thing working by going to admin/config/people/accounts/fields
I saw that Group audience - number of values are already set as unlimited but I selected all the target bundles available and save it and it started working fine for me.

paul.kim’s picture

I was having this issue with both admin and my generated test users. I managed to fix this by a combination of steps above, without being a 100% certain, I suspect the issue was caused by the rapid addition/deletion while testing (so a db issue).

Removing the Group and Groups audience field from /admin/config/group/fields has done the trick. I then checked Organic Group tab on the content type settings /admin/structure/types/manage/ to ensure that both Group and Group content were unchecked (my content type uses both). I had to manually uncheck the Group checkbox, then ran a cache clear and added the Group audience field (og_group_ref) back via /admin/config/group/fields.

So far so good!

bburg’s picture

Sorry if this seems a bit rambling, I was writing and learning simultaneously.

One note, checking the box for "Group manager full permissions" at admin/config/group/settings seems to resolve the issue. But it does seem odd that users who should be able to can't create groups. Also, the workflow/content access on the site I'm working on now are wound up so tight, I'm worried this may break something else...

@evilehk I see the code in og_field_access_field_access you describe:


  if (!$id && $op == 'edit' && (og_is_group($entity_type, $entity) || og_is_group_content_type($entity_type, $bundle))) {
    // This is create form of a non-saved entity, so we check
    // permissions to access the field, for all the groups the user is a
    // member.
    foreach (og_get_entity_groups() as $group_type => $gids) {
      foreach ($gids as $gid) {
        if (og_user_access($group_type, $gid, $perm)) {
          return TRUE;
        }
      }
    }
    return FALSE;
  }

But this block is never entered when creating a group node. The $op value we are checking is 'view', because that was the way field_access() was called from og_get_best_group_audience_field(). It seems irrelevant to check the access for existing groups when creating a new group. I think this snippet is intended for other purposes. The remainder of this function is what actually returns the resulting permission value.


  $access = og_user_access_entity($perm, $entity_type, $entity, $account);
  if (!is_null($access)) {
    return $access;
  }

So to get this straight, og_user_access_entity is checking for the permission defined earlier by:


$perm = $op == 'view' ? 'view ' . $field['field_name'] . ' field' : 'update ' . $field['field_name'] . ' field';

which results in the permission 'view og_user_node field' (actually 'view og_user_node1 field' for me, I'm not sure how it got that way). However, this permission does not exist. Perhaps this should be dynamically created in og_list_permissions() ?

bburg’s picture

Follow up to my above comment, I determined that og field access already provides an access permission for "View Membership field" in the og permissions. I was able to create a new Group after giving this permission to the group members role.

evilehk’s picture

Thanks for sharing that good info, @johnbburg. I think you mean "View Group membership field". On that note, following the steps from comment #3 will reproduce the error message. Enabling the View Group membership field permission for member role will make the error message go away.

I believe what's happening is during form validation, the og_form_group_manager_validate method is called if the author is set to become the group manager. The purpose of this validation method is to make sure the author has a group-membership field. In most cases, this is the og_user_node field of the user object.

With Organic groups field access enabled, OG must make sure that the author has access to view the og_user_node field. For new entities, the field_access hook in Organic groups field access module searches for all group the user is a member. If it finds a group the user is an administrator member of, then it can check that role for access to View group membership field (og_user_node) permission. If the user does not have previous group content but is a member of a group, then it only finds the member role. Therefore, the member role must have access to the View group membership permission or validation fails.

It's really up to debate if this is a bug or as-designed. The only "fix" I can think of is making the group membership field a special field ignored by the og field access module, which is not ideal.

evilehk’s picture

One solution can be that if og_field_access is enabled and we are saving a new node, then skip the access check for the group audience field in the og_form_group_manager_validate function. Patch attached. The patch does not include the code in #50, which is a specific case for a deleted group not yet deleted from og_membership pre-cron.

emjayess’s picture

Wow this is obtuse. I feel like I've traveled back in time a dozen years and am troubleshooting windows illegal operation exceptions.

"Create a role, and let that role create new groups"... should've expected that to be near impossible. I'm sorry for the unhelpful sarcasm, but I am trying to build a project with a social fabric, and it seems like every day introduces a new blocker like this that puts the whole thing on ice.

UPDATE: tip in #58 seemed to do the trick for me... selecting all the target bundles; it would seem sensible, though, if this only checked against the specific target bundle that the user is actively adding, right?

ehsankhfr’s picture

Hey all,

I am using the last version of this module and also the last version of the drupal 7!

I receive also the same error!

Any solutions?!

ehsankhfr’s picture

Ok, #59 Worked well for me.

The complete log of the solved problem:
Date: 28,Aug,2014
Drupal 7.31 and OG 7.x-2.7 are used.

nbouhid’s picture

Hello guys, I'm also having this issue because I can't set the reference field to unlimited for business reasons. So I'm just going to force groups author to be "Anonymous" as jhedstrom said on #51.
Hope it helps somebody.

I guess that it should be easier in order to get just one user/role that will create and manage all groups. Maybe for simpler cases, it's better just to use a taxonomy.

wirka’s picture

Hello, I have had the same problem before, I use organic groups version 7.x-2.7 and Field Permissions beta2, under "Group membership field settings" at /admin/config/people/accounts/fields/og_user_node please make sure at least user role has permission to "View own value for field Group membership". Cheers.

Anonymous’s picture

Hi,

I've had the same problem but changing 'Number of values' to unlimited on admin/config/people/accounts/fields has worked without having to apply any patches.

Using OG 7.x-2.7

Thanks,

Stephen

mspikes’s picture

After banging my head against a wall due to an "access denied" issue when trying to access the forums -- #59 worked for me as well.

thomasaaron’s picture

I've tried pretty much every suggestion on this page. The only thing I can get to work is disabling the Organic Groups Field Access module. About to give up on Organic Groups. I've wasted a whole day screwing around with this.

rick_p’s picture

OK, like others I beat my head against the wall for hours on this, but I had no choice, giving up on OG was/is not an option. First let me point out that the only reason I found this page was due to changing the Number of Values for the Group membership field settings in admin/config/people/accounts/fields/og_user_node to something other than the default "unlimited," which gave me the permissions error everyone is, or was struggling with here. That problem goes away when I put that setting back to unlimited.

However, my initial problem was worse, trying to create my first group after content type creation generated a fatal exception resulting in "the website encountered an error, please try again later." If setting the Number of Values for the Group membership field settings doesn't solve your problem, try this...

Add your new content type to the Target Bundles in the Entity Selection of the Groups Audience Field Settings of your "Basic Page" located at (admin/structure/types/manage/page/fields/og_group_ref). You have to select (highlight) all the items in the Target Bundles list and then Save the settings. If this is not applicable to your setup, as in you haven't added Groups Audience to you basic page, then it is likely coming from some other content type. If you have a lot of content types and don't know where to begin, go to Recent Log Messages (admin/reports/dblog), find the most recent error related to the issue, open it, and look for something like this...

OgException: OG membership can not be created in entity node and bundle page using the field og_group_ref as the field does not reference yourContentType bundle in node entity type. in OgMembership->save() (line 62 of /Users/yourprofile/Sites/yourdomin.com/your_path/sites/all/modules/og/includes/og.membership.inc).

I bolded "page" in my case but yours might be some other content type, that location in the error message is your case.

I hope this helps someone avoid the wasted hours I put into this. ~Rick

stevesmename’s picture

I'd suggest to first try disabling og_field_access module, don't uninstall just disable. Then you can test, and if problem is gone you can narrow down the issue is within og_field_access.module. You can then re-enable the module and permissions will persist as they were before you disabled the module. If it is related to og_field_access.module, then in my experience its one or both of the following:

Syntapse’s picture

subscribing. ive raised a duplicate issue on this https://www.drupal.org/node/2660408 but no replies. I came to the same conclusion... erreoneous coupling between og_core and the og_field_access module.

Is OG still being actively maintained? I see the last action on this thread is 9 months old. Ive spent weeks trying to build a system and my project has come to a standstill not sure if i should abandon OG and try something else. Im grateful for any early feedback...

paultrotter50’s picture

Like #73 this issue would go away when the og_field_access module was disabled, but I need access control.

This patch seems to have removed the problem on my clean install site that I replicated the issue on.

kyle.veldhuizen’s picture

I am having this issue when the "Group manager full permissions" check box is unchecked in admin/config/group/settings.

Once checked I am able to create multiple groups with a user.

I still have the og_field_access module enabled.

Update:

The issue for me seems to be when a manager does not have the "View Group membership field" permission under the "Organic groups field access" section in admin/config/group/permissions/node/group name

kari.kaariainen’s picture

This is my testing setup: Core 7.43, OG 7.x-2.8, All OG modules enabled except Organic groups register.

Group type, Group content type and a user has been created with proper fields for access control.

"Group manager full permissions" check box is unchecked in admin/config/group/settings.

"authenticated user" role has all (core)permissions except "Administer Organic groups permissions".
"administrator member" role for our group type has all (og)permissions.
"member" role for our group type has no (og)permissions.

In this setup, authenticated user can not create a group. Error:
"Can't save entity as group, because user username can't be subscribed to group and become a manager."

If I add (core)permission "Administer Organic groups permissions" to "authenticated user" role, authenticated user can create a group.
OR
If I add (og)permission "Administer group" to "authenticated member" role, authenticated user can create a group.

stephandale’s picture

Likewise, for me this was caused by the og_field_access module denying 'view' access to the og_group_ref field.

Specifically, there is a check in the og_get_best_group_audience_field() function of og.module (line 1911) that is used by og_form_group_manager_validate(). This check fails and we end up on the "Can't save entity as group" error.

    if (!$skip_access && !field_access('view', $field, $entity_type, $entity)) {
      // User can't access field.
      continue;
    }

To get rid of the error, I edited the field permissions of My OG at admin/config/group/permissions/node/my_og and granted "View Groups audience field" permission to Non-member and Member.

Btw I also have multiple og_group_ref_... fields defined on the user - one for each of my OG content types. These are set to unlimited, specify a particular target bundle (the OG content type) and a specific OG membership type (I have one OG membership type per OG content type).

Shane Birley’s picture

What if we don't use field access outside of the basic member/non-member register. This problem seems to stem from whether or not a user can create more than one group.

If the registration field is set to allow people to register to only a single group (in our example, during user registration) the issue appears -- but if we allow users to join more than one group at a time (set the field to unlimited) the problem goes away.

Yet this is not ideal since we only wish to give them a single choice during registration and have admin users be able to create as many groups as are needed.

thomasaaron’s picture

It's funny. I posted to this form post (#71) 2 years ago. None of the suggestions worked, and I ditched Organic Groups in favor of GCC. However, I had forgotten all about this and ran into the same problem again. Turns out, #78 solved it for me. Thanks Stephandle.

thomasaaron’s picture

When running OG Groups, I find that if:

1. I delete all my groups, and ...
2. Try to create a new group ...

I get: "Can't save entity as group, because user Thomas Aaron can't be subscribed to group and become a manager."

If I run Cron manually, it fixes the problem.

I think this is because there is still crap in the database that hasn't been deleted and is hosing things. Once Cron runs, everything is a-okay. So, I set my cron to run every one hour via Admin/Config/System/Cron.

That's a good enough fix for my particular application, as people won't be deleting ALL their groups on any kind of regular basis. If they do, it will just shut them down for one hour. I can live with that.

Just wanted to throw this out there in case anyone else wants to see if this does the trick.

Aporie’s picture

#11 fixed the issue for me.

Ajascosoft’s picture

I am using Opigno LMS and had the same problem when creating courses.
I changed the OG configuration to include courses, the target bundle was initially active for only Classes. (admin/config/people/accounts/fields/og_user_node). I added "Courses" to it and it solved the problem.
Hope it helps someone else.