Warning message

Documentation is currently being migrated into the new system. Some pages might be temporarily missing, and some guides might appear empty. Thank you for your patience while we are improving Drupal.org documentation.

HowTos

Subscribe a user to specific OG group using Rules

Last updated on
November 1, 2016 - 16:31

The following export is from pandaPowder's comment in OG issues:
https://www.drupal.org/node/1944508#comment-7738077

Works with OG 7.x-2.7 and Rules 7.x-2.7

Use the Import function of Rules (http://domain.com/admin/config/workflow/rules/reaction/import)and paste the code below. You can then modify to your group name and ID.

{ "rules_start_first_course_on_create" : {
    "LABEL" : "Start First Course  on create",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "groups" ],
    "REQUIRES" : [ "rules", "og" ],
    "ON" : [ "user_insert" ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "node", "value" : "71" },
          "PROVIDE" : { "variable_added" : { "foundation_course" : "Foundation Course" } }
        }
      },
      { "og_subcribe_user" : { "user" : [ "account" ], "group" : [ "foundation-course" ] } }
    ]
  }
}

This simple export helped tremendously because I was getting lost in the weeds of Rules and took me two days of Google-ing to find.