Hi there,
I need to assign a user to a specific group each time the newly created user is given a specific role.
I´ve set:
Event: After saving a new user account
Condition: User has role(s)...

And then what should I do? The action is a problem if you want to give that user an arbitrary group membership? (not from context but manually set the NID of the group). I don´t get any way to manually put the user group NID, so I thought that maybe I could do that with "Execute custom PHP code". But have no clue on what should I achieve that...

Thanks for your help!!

Rosamunda

Comments

pandaPowder’s picture

I have the same problem. I just want to say when the user is created subscribe the user to group 71 (for example) I don't need a data selector or a contextual selector.

pandaPowder’s picture

Category: task » support
pandaPowder’s picture

I figured out how to do this by adding a variable in rules. I think I struggled with it mainly because I don't know rules very well yet so maybe this support request belongs in rules :). It would have been easier for me to implement hook_user_insert and do it programmatically but I thought it would be good to try it with rules.

Anyway, here's the rule I made which is working fine for my simple case. You should be able to import it using the rules ui and tweak it for your purposes.

{ "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" ] } }
    ]
  }
}
pandaPowder’s picture

Status: Active » Closed (fixed)