Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
pandaPowder CreditAttribution: pandaPowder commentedI 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.
Comment #2
pandaPowder CreditAttribution: pandaPowder commentedComment #3
pandaPowder CreditAttribution: pandaPowder commentedI 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.
Comment #4
pandaPowder CreditAttribution: pandaPowder commented