Sending messages based on flag information

Events happening in the community are now at Drupal community events on www.drupal.org.
itangalo's picture

I got this question in my mailbox, and thought I should write an answer where anyone can see and comment.

I watched your screencast about VBO and rules. It was awesome and helpful for sure. I have a question though.

Users on my site create blogs and these blogs can be "bookmarked" using flag module.
Is it possible to have the author of a new blog content send a private msg/email to all users who have bookmarked a piece of their blog content previously?

If that is too difficult is it possible to at least send the privatemsg/email to all friends of the author?

Thanks a ton for all your help and work with the modules on Drupal!

When tackling question/problems like these, I break them up in a few steps:

  1. Can I create a view that lists all the objects I want to perform an action on?
  2. Can I create an action that does what I want?
  3. Can I get a reasonable trigger for the event?
  4. Can I get all the information I need from the trigger, and can I send the necessary information along in the Rules/VBO chain?

In the first case -- sending an e-mail to everyone who has bookmarked a node -- it will unfortunately fail in the first step. Flag does not, for some reason, expose the UID of the flagger to Views. That means that you cannot make a Views list of 'everyone who has flagged content X' (which otherwise could be done in a clean and neat way using arguments in Views).
I posted an issue about this just a few days ago: http://drupal.org/node/939500
Anyone with coding skills is welcome to make a try for a patch!

The second case is much easier, though. Eventhough Flag doesn't expose the flagger UID, you have options 'include only content flagged by current user' when you add the Flag as a relationship in Views. If friends are flagged users (which I assume), you can pretty quickly make a list of all users the active user has flagged. Turn the view into a VBO and use the action 'Send e-mail to user' (or similar) and you got yourself a tool for letting members contact their friends.
The problem here is, again, that it must be the acting user. You can't (presently) make a list of friends of user Y and send e-mails.

Thanks for the kind words, and good luck with future Rules/VBO endeavors!
//Johan Falk, NodeOne, Sweden

Comments

hey thanks

jrivelli's picture

Thank you much for that! I will wait till a patch comes out and attempt to tackle this. I haven't fully grasped the whole concept of VBO yet the way you do it, but it looks super powerful for sure!
Again, I appreciate your help in keeping this community going strong :)

It already exists!

itangalo's picture

It turns out that I was utterly wrong about Flag not having the functionality I mentioned – it does! In the issue there is now a link to a description of how to use it.

Basically the trick was that you have to add yet another relationship to be able to use the flagging user as an argument.

Good luck!
//Johan Falk, NodeOne, Sweden

Alrighty

jrivelli's picture

I'm not sure how I would automate this with rules though? I can do all the above mentioned, no problem. In fact, the bookmarks is already a created tab on user's profile pages. My main mission is to be able to send a private msg to users when someone they have bookmarked posted new content of a certain type.

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: