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

spidersilk’s picture

Were you ever able to solve this, Rosamunda? I'm having the same issue.

tr’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

Well the use case is a little vague - when you say "assign a user to a specific group each time the newly created user is given a specific role" and you show the event as "After saving a new user account", that indicates to me that the Rule you are writing only triggers when the user is created for the first time. But that contradicts the second part of your statement "each time the ... user is given a specific role" because that is not something that happens when the user is created for the first time - you're describing a user being MODIFIED, or updated and the user's list of roles being changed.

So I would reaction on "After updating a user", I would first check to see if the roles have changed and if they have then loop over the list of roles and set the group based on the role. To do this, you will need to create data somewhere that has a map of which role gets which group. You could do this with a taxonomy vocabulary if you don't want to program, but it would be more efficient and easier IMO to write a custom action which sets the groups for your roles.