2

When users registers on my site, they choose their State of Origin.

Using Rules I would like to configure a rule which sends an email to all users from the same state when a user from that state edits his/her profile.

Is this possible using Rules or is there another approach?

4

Without knowing anything about your entity & field setup I can't give you an exact rules that will work however it is possible and I can give you a pseudo rule:

  • Install the rules bonus pack module.
  • Install the rules conditional module (I think you need this but I'm not actually looking at a site to confirm).
  • Create a view that lists all users with a contextual filter of the state field. - So when you call the view with a specific state you get all users who have selected that state.
  • Event: Before user profile is saved.
  • Action: Rules bonus pack action "Load a user list with Views". Use the user email list view from earlier and pass in the value of the state from the new user object (from after the edit).
  • Action: Loop through the user list you loaded from the view.
  • Action: In the user list loop send an email to the loop user object.

This will also send an email to the user who is actually changing their profile. if you want to exclude them you can either add more conditions in the rule to check against the edited user object or you can add another contextual filter to the view for uid, check the box in that contextual field to exclude that user from the results and then also pass in the uid as a contextual filter in the rule.

I would do that latter because it is a less complex rule and I would assume it would use less resources to run.

  • Thank you. It worked. I however used Views Bulk Operations instead of rules bonus pack. Can you edit your answer accordingly? – seyi Nov 1 '14 at 14:52
  • Feel free to create a new answer with regards to views bulk operations. I'm not sure how views bulk operations helps in this case. – rooby Nov 2 '14 at 16:21
  • Oh I see now how you do it with VBO. I feel like that is also a valid solution but a different solution so it should probably have its own answer (there are a number of parts of the setup that differ). – rooby Nov 2 '14 at 16:36
  • 1
    @rooby : thought I'd post the VBO-based solution, as an alternative to your solution (not sure why OPer never did ...) – Pierre.Vriens Aug 16 '16 at 12:05
1

Yes this is possible with Rules, if combined with Views Bulk Operations, as further detailed below ...

What you actually need to do is similar to what is shown in the video about Using VBO to load list of objects into Rules, starting from about 5:30, up to 11:30. Here is a summary of what is shown in this video (quote from the linked page):

  • You need a view that lists the entities you want to work on in Rules. Note that you don't need a display of the view – and it might even be better not to have one if you don't want the view to be displayed somewhere.
  • However, you need one bulk operations field. The type of bulk operations field determines what entity type will be sent to Rules. Note that you don't need any actions enabled for the field – it is enough that it is present.
  • You need a rule that, as an action, loads entities from a VBO. (This is available under the "Views bulk operations" group.) All view displays with at least one VBO field will be selectable.
  • The action provides a list of entities, that can be used just like other lists in Rules. Combine with loops, actions and Rules Scheduler to make awesomeness happen.

In your case you want to start from a VBO list of all the users you want to get processed (= "all users from the same state", as in your question). And for each user in the list you want the Rules Action to be "send an eMail" (instead of "remove sticky").

Easy, no? Happy VBO-ing with Rules ... ( or Rules-ing with VBO if you prefer)!

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.