1

This is a configuration task.

it continues the request here: Automatic add user to organic groups

Task

Using Rules UI: all new users are automatically members to group MyCommunity

Steps

  1. Events: After saving a new user account
  2. Conditions : none
  3. Actions: OG: Add entity to a group

But how to configure data selector to get a specific group: MyCommunity?

UPDATE

Apparently there is no clean way to do that other by a patch: https://drupal.org/node/1706884

1

One of the elements you can use under actions is "Fetch entity by id". Say the node id of your MyCommunity group is 10, then the Entity type value will be Node, and the Identifier value is 10. In the Provided variables section, you give your fetched entity a label and variable name. Let's give it a label of MyCommunity, and name it my_community. Save the action element. The next action element to add is "Add entity to group". The Entity data selector is the new user so give it the value of "account". Then under group, the data selector is the variable name we created in the previous step, which is "my_community". I tested this out locally and it worked. Here's an export of the rule.

{ "rules_115407" : {
    "LABEL" : "115407",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "stackexchange" ],
    "REQUIRES" : [ "rules", "og" ],
    "ON" : { "user_insert" : [] },
    "DO" : [
      { "entity_fetch" : {
          "USING" : { "type" : "node", "id" : "10" },
          "PROVIDE" : { "entity_fetched" : { "my_community" : "MyCommunity" } }
        }
      },
      { "og_group_content_add" : { "entity" : [ "account" ], "group" : [ "my_community" ] } }
    ]
  }
}
0

A much simpler approach tha works well on my site:

{ "rules_new_members_belong_to_this_group" : {
    "LABEL" : "22 - New members automatically belong to this group",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "0",
    "OWNER" : "rules",
    "REQUIRES" : [ "og", "rules" ],
    "ON" : { "user_insert" : [] },
    "DO" : [ { "og_subcribe_user" : { "user" : [ "account" ], "group" : "24" } } ]
  }
}

24 is the gid or group ID number. When you create the rule it is the name of the group that you select, not its ID number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.