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.

Files: 
CommentFileSizeAuthor
#50 og-cant-save-entity-as-group-1538658-50.patch928 bytesevilehk
PASSED: [[SimpleTest]]: [MySQL] 894 pass(es).
[ View ]

Comments

Status:Active» Closed (cannot reproduce)

I can't reproduce on a new fresh install.

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.

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...

Status:Closed (cannot reproduce)» Active

Marking as active based on the reproduction steps.

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?

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?

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

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

Please answer question in #5

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.

> 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?

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?

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!

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?

You can safely create it manually.

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.

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

Do you have a content type defined as group?

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...

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.

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.

Field is not created on my setup either...

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!

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)?

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!

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.

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!

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.

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.

StatusFileSize
new28.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.

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.

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

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.

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

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

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?

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

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.

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."

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.

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.

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.

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.

#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...

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

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.

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.

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.

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.

Issue summary:View changes
Status:Active» Needs review
StatusFileSize
new928 bytes
PASSED: [[SimpleTest]]: [MySQL] 894 pass(es).
[ View ]

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

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.

Priority:Normal» Major

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.

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.

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.

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....

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

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.

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!