Posted by Anonymous on July 1, 2013 at 4:21pm
I have various content types that are associated with my OG 7.x-2.x groups. When a site member who is not a member of any group attempts to create content using any of the these content types they cannot create new content.
If a site member is a member of at least one OG, then they can use the content type and create content.
I want site members to be able to use these content types regardless of whether they belong to one or more organic groups. Failing that, I would like to create a generic group that all members are forced to join on registration.
What are my options?
Comments
Follow up: Must be OG member to add content to an OG
I should clarify one thing, I still want to limit the ability of a site member to add content to a particular Group. I want only Group members to be able to add content to a specific group.
My OG permissions are configured to allow all site registered members to view Organic Group content for all groups. To add content to a Group, a site member must join the Organic Group.
The problem arises when a new site member attempts to add content to the site, even though they have not yet joined any Organic group. The site is designed to allow this User interface. For example, I have a content type called Reviews that any site member should be able to use. All reviews are then listed in a View, regardless of which specific OG group they may be associated with. If a site member happens to be a member of any Organic group, they can add new "Review" content.
Trying to solve with Rules
The more I think about this it should be solvable with Rules module. I will give it a try and update if it works.
Can't seem to figure this out
added Group audience and Group membership fields to Account Settings. (og_group_ref and og_user_node). Tried setting each to "Required Field" and "Display on user registration form".
Each field then showed up on the user's initial registration form, not really appropriate as I only want to capture user name and email address at that stage. Anyway, each field was empty so it really didn't matter anyway.
Rules didn't seem to work. Out of ideas!
Link to more info
https://drupal.org/node/1706884#comment-6336460
Finally got it working with Rules
I managed to get this working by setting up a rule to redirect users to the node of a group after they register, then run a rule when they hit that group node to make them a member of the group.
It is a bit if a mess but works. If anyone needs the rules settings details let me know.
Workflow Rules used to Auto register OG 7.x-2.x.dev
The following is the "export" from the three Rules I created to auto register all new site members in a group called RLE Community Group. This group was created because members are able to create content using various content types that are associated with groups.
Newly registered site members generally have not joined any Organic Group, but they want to post a review or other content to the site homepage. As they are not a member of ANY OG, they cannot access these content types given the OG permissions I have set for all groups.
These rules "auto register" a new member as soon as they validate their account by logging in for the first time. These rule "exports" can be a little confusing, but if you are careful you should be able to reproduce the same logic on your site. You may need to set the "weight" of each Rule to make sure they process in the correct order:
If you need help, just ask:
Rule 1: Registration Validation Redirect to Community OG auto Subscribe page
{ "rules_registration_validation_redirect_to_community_og_auto_subs" : {
"LABEL" : "Registration Validation Redirect to Community OG auto Subscribe page",
"PLUGIN" : "reaction rule",
"WEIGHT" : "2",
"TAGS" : [ "og" ],
"REQUIRES" : [ "rules" ],
"ON" : [ "user_update" ],
"DO" : [ { "redirect" : { "url" : "node\/1858" } } ]
}
}
Rule 2: Member joins OG Group Automatically
{ "rules_member_joins_og_group_automatically" : {
"LABEL" : "Member joins OG Group Automatically",
"PLUGIN" : "reaction rule",
"TAGS" : [ "og" ],
"REQUIRES" : [ "rules", "og" ],
"ON" : [ "node_view" ],
"IF" : [ { "data_is" : { "data" : [ "node:nid" ], "value" : "1858" } } ],
"DO" : [
{ "og_subcribe_user" : {
"user" : [ "site:current-user" ],
"group" : [ "site:og-context--node" ]
}
}
]
}
}
Rule 3: redirect from Community OG Page
{ "rules_redirect_from_community_og_page" : {
"LABEL" : "redirect from Community OG Page",
"PLUGIN" : "reaction rule",
"WEIGHT" : "1",
"TAGS" : [ "og" ],
"REQUIRES" : [ "rules" ],
"ON" : [ "node_view" ],
"IF" : [ { "data_is" : { "data" : [ "node:nid" ], "value" : "1858" } } ],
"DO" : [ { "redirect" : { "url" : "groups" } } ]
}
}
Thanks for the solution
Thanks for the solution, it work for me.
Just change 1858 to node ID of the compulsory group. Rule 3 is not compulsory, but it is a nice way to redirect your first time user to a 'welcome' or 'tour' page.
Don't give up i.reborn Drupal
Don't give up i.reborn Drupal is a massive learning curve, and OG, especially the 7.x-2.x.dev release is extremely confusing, but there is an excellent logic to this release of OG.
Let me know if you need specific help.
Another way of doing this.
This is where my systems always fails:
Whenever I play around with any fields in my system, I allways get the following message when I try to create users or groups afterwards:
OgException: There are no OG fields in entity user and bundle user referencing node - private_group. in og_group() (line 1956 of /var/www/www.zooot.net/htdocs/sites/all/modules/og/og.module).
Kind regards,
Paul
Zooot Net
Your Own Social Network.
Use secure communication with OpenPGP.
Encrypt with public key: 34A447B1675A9463
Verify key with hash: 570C 0051 3B68 CAFB 98BA 1EEF 34A4 47B1 675A 9463
Okay, managed to make it work.
Kind regards,
Paul
Zooot Net
Your Own Social Network.
Use secure communication with OpenPGP.
Encrypt with public key: 34A447B1675A9463
Verify key with hash: 570C 0051 3B68 CAFB 98BA 1EEF 34A4 47B1 675A 9463
Having problems with the OG data selectors in Rules.
Hi all,
another month, another challenge. This time I set out to build a rule that will automatically add confirmed relationships (UR) to the private groups of the requester and the requestee.
Been to the rules group already but nobody there seems to have any experience with OG-Rules. So maybe somebody here can help.
My site (https://www.zooot.net) uses a rule to autocreate a private group upon account registration using the registration name. If your name is "bob" your group will be named "bob". Here is the rule:
{ "rules_auto_create_user_group" : {"LABEL" : "Auto Create User Group",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_insert" ],
"DO" : [
{ "entity_create" : {
"USING" : {
"type" : "node",
"param_type" : "private_group",
"param_title" : "[account:name]",
"param_author" : [ "account" ]
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
}
]
}
}
Now I want to integrate a rule, that will subscribe users to each others private groups when they form a confirmed relationship with each other.
This was my first semi-successful try:
{ "rules_add_contacts_to_groups_" : {"LABEL" : "Add contacts to groups.",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "og", "user_relationships_rules" ],
"ON" : [ "user_relationships_approve" ],
"DO" : [
{ "og_group_content_add" : {
"entity" : [ "requester" ],
"group" : [ "requester:og-user-group-ref:1:author:og-user-group-ref:1" ]
}
},
{ "og_group_content_add" : {
"entity" : [ "requestee" ],
"group" : [ "requester:og-user-group-ref:1:author:og-user-group-ref:1" ]
}
}
]
}
}
Problem: This rules seems to select the group to which to add in an alphabetical order. I am unable to understand the selector option offered to the group:
requestee:og-user-group-ref Group membership Field "og_user_group_ref".requestee:og-user-group-ref:0: Group membership Field "og_user_group_ref".
requestee:og-user-group-ref:1: Group membership Field "og_user_group_ref".
requestee:og-user-group-ref:2: Group membership Field "og_user_group_ref".
requestee:og-user-group-ref:3: Group membership Field "og_user_group_ref".
requestee:og-membership OG memberships A list of all OG memberships of the user entity.
requestee:og-membership:0: OG memberships A list of all OG memberships of the user entity.
requestee:og-membership:1: OG memberships A list of all OG memberships of the user entity.
requestee:og-membership:2: OG memberships A list of all OG memberships of the user entity.
requestee:og-membership:3: OG memberships A list of all OG memberships of the user entity.
requestee:og-membership--1 Active OG membership A list of all OG memberships of the user entity with Active state.
requestee:og-membership--1:0: Active OG membership A list of all OG memberships of the user entity with Active state.
requestee:og-membership--1:1: Active OG membership A list of all OG memberships of the user entity with Active state.
requestee:og-membership--1:2: Active OG membership A list of all OG memberships of the user entity with Active state.
requestee:og-membership--1:3: Active OG membership A list of all OG memberships of the user entity with Active state.
requestee:og-membership--2 Pending OG membership A list of all OG memberships of the user entity with Pending state.
requestee:og-membership--2:0: Pending OG membership A list of all OG memberships of the user entity with Pending state.
requestee:og-membership--2:1: Pending OG membership A list of all OG memberships of the user entity with Pending state.
requestee:og-membership--2:2: Pending OG membership A list of all OG memberships of the user entity with Pending state.
requestee:og-membership--2:3: Pending OG membership A list of all OG memberships of the user entity with Pending state.
requestee:og-membership--3 Blocked OG membership A list of all OG memberships of the user entity with Blocked state.
requestee:og-membership--3:0: Blocked OG membership A list of all OG memberships of the user entity with Blocked state.
requestee:og-membership--3:1: Blocked OG membership A list of all OG memberships of the user entity with Blocked state.
requestee:og-membership--3:2: Blocked OG membership A list of all OG memberships of the user entity with Blocked state.
requestee:og-membership--3:3: Blocked OG membership A list of all OG memberships of the user entity with Blocked state.
requestee:og-user-group-ref--og-membership OG membership from field Group membership A list of all OG memberships registered in field Group membership.
requestee:og-user-group-ref--og-membership:0: OG membership from field Group membership A list of all OG memberships registered in field Group membership.
requestee:og-user-group-ref--og-membership:1: OG membership from field Group membership A list of all OG memberships registered in field Group membership.
requestee:og-user-group-ref--og-membership:2: OG membership from field Group membership A list of all OG memberships registered in field Group membership.
requestee:og-user-group-ref--og-membership:3: OG membership from field Group membership A list of all OG memberships registered in field Group membership.
requestee:og-user-group-ref--og-membership--1 Active OG memberships from field Group membership A list of all OG memberships with Active registered in field Group membership.
requestee:og-user-group-ref--og-membership--1:0: Active OG memberships from field Group membership A list of all OG memberships with Active registered in field Group membership.
requestee:og-user-group-ref--og-membership--1:1: Active OG memberships from field Group membership A list of all OG memberships with Active registered in field Group membership.
requestee:og-user-group-ref--og-membership--1:2: Active OG memberships from field Group membership A list of all OG memberships with Active registered in field Group membership.
requestee:og-user-group-ref--og-membership--1:3: Active OG memberships from field Group membership A list of all OG memberships with Active registered in field Group membership.
requestee:og-user-group-ref--og-membership--2 Pending OG memberships from field Group membership A list of all OG memberships with Pending registered in field Group membership.
requestee:og-user-group-ref--og-membership--2:0: Pending OG memberships from field Group membership A list of all OG memberships with Pending registered in field Group membership.
requestee:og-user-group-ref--og-membership--2:1: Pending OG memberships from field Group membership A list of all OG memberships with Pending registered in field Group membership.
requestee:og-user-group-ref--og-membership--2:2: Pending OG memberships from field Group membership A list of all OG memberships with Pending registered in field Group membership.
requestee:og-user-group-ref--og-membership--2:3: Pending OG memberships from field Group membership A list of all OG memberships with Pending registered in field Group membership.
requestee:og-user-group-ref--og-membership--3 Blocked OG memberships from field Group membership A list of all OG memberships with Blocked registered in field Group membership.
requestee:og-user-group-ref--og-membership--3:0: Blocked OG memberships from field Group membership A list of all OG memberships with Blocked registered in field Group membership.
requestee:og-user-group-ref--og-membership--3:1: Blocked OG memberships from field Group membership A list of all OG memberships with Blocked registered in field Group membership.
requestee:og-user-group-ref--og-membership--3:2: Blocked OG memberships from field Group membership A list of all OG memberships with Blocked registered in field Group membership.
requestee:og-user-group-ref--og-membership--3:3: Blocked OG memberships from field Group membership A list of all OG memberships with Blocked registered in field Group membership.
These options really do not make any sense to me. Is there a way to select a group based on the name (requester:name) or (requestee:name)?
Next I tried this approach:
{ "rules_add_contacts_to_groups_" : {"LABEL" : "Add Relationships to Private Groups",
"PLUGIN" : "reaction rule",
"TAGS" : [ "UR OG Rules" ],
"REQUIRES" : [ "rules", "og", "user_relationships_rules" ],
"ON" : [ "user_relationships_approve" ],
"DO" : [
{ "entity_query" : {
"USING" : {
"type" : "node",
"property" : "group_group",
"value" : [ "requester:name" ],
"limit" : "1"
},
"PROVIDE" : { "entity_fetched" : { "entity_fetched_requester" : "Fetched entity" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "entity-fetched-requester" ] },
"ITEM" : { "list_item_requester" : "Current list item" },
"DO" : [
{ "og_group_content_add" : { "entity" : [ "requestee" ], "group" : [ "list-item-requester" ] } }
]
}
},
{ "entity_query" : {
"USING" : {
"type" : "node",
"property" : "group_group",
"value" : [ "requestee:name" ],
"limit" : "1"
},
"PROVIDE" : { "entity_fetched" : { "entity_fetched_requestee" : "Fetched entity_requestee" } }
}
},
{ "LOOP" : {
"USING" : { "list" : [ "entity-fetched-requestee" ] },
"ITEM" : { "list_item_requestee" : "Current list item" },
"DO" : [
{ "og_group_content_add" : { "entity" : [ "requester" ], "group" : [ "list-item-requestee" ] } }
]
}
}
]
}
}
Unfortunately this does not do anything. It does not produce any errors, but it also does not add the realtionships to the groups.
Here is the debug-log:
Rules debug information:
" Reacting on event A user relationship has been approved.
0 ms Reacting on event A user relationship has been approved.
64.12 ms Evaluating conditions of rule Add Relationships to Private Groups. [edit]
64.199 ms AND evaluated to TRUE.
" Rule Add Relationships to Private Groups fires. [edit]
0 ms Rule Add Relationships to Private Groups fires.
4.964 ms Evaluating the action entity_query. [edit]
63.974 ms Added the provided variable entity_fetched_requester of type list<node> [edit]
65.293 ms Looping over the list items of entity-fetched-requester [edit]
67.289 ms Evaluating the action entity_query. [edit]
76.72 ms Added the provided variable entity_fetched_requestee of type list<node> [edit]
78.319 ms Looping over the list items of entity-fetched-requestee [edit]
78.54 ms Rule Add Relationships to Private Groups has fired.
143.008 ms Finished reacting on event A user relationship has been approved.
Severity notice
Where is my error? Does anyone know?
Kind regards,
Paul
Zooot Net
Your Own Social Network.
Use secure communication with OpenPGP.
Encrypt with public key: 34A447B1675A9463
Verify key with hash: 570C 0051 3B68 CAFB 98BA 1EEF 34A4 47B1 675A 9463
sub
sub
Simplest solution with Rules
After user subscribes,
action: add a variable, choose node, direct input, type in the node ID.
next action: subcribe user to group. Select the variable.
not working on user registration event
the problem with user registration is you cannot use this solution cause "current user" is still anonymous cause not logged in...
so...you could use an event on fter user login but is not the best solution i guess..
So Rules. Such Mess. Very Complicate. Wow.
While there are indeed many ways to skin a cat, they all seem equally messy. As an alternative to many of the above approaches, I'd recommend something much simpler that can be done in just a few lines of code in your custom module:
Automatically add new users to an organic group in just a few lines of code
As implemented on the original NYC Camp site.