3

How can I leverage the Rules module to look for nodes where a CCK field has a specific value, and when found, email those node authors?

For example, if I wanted people to login and update their profile when I add a new CCK field, how would I do that?

1

If you want to use rules for that, you would have to create your own event: when you add a CCK field. You would then have to write some code to trigger then event when a new CCK field is added, and supply rules with the nodes of that type or whatever data you would need in your rule.

My guess is that the amount of custom coding needed for this to work, would be more than what is needed to just do this yourself in a custom module, with hook_mail. Also you might have problems configuring the rule to do what you need. I haven't tried using an array of data types in rules, so that might make things more complicated for you as well.

1

Just another bit of input here: http://www.midwesternmac.com/blogs/jeff-geerling/sending-thousands-automated-sc

I had to build a system that was much more scalable than directly shooting off hundreds or thousands of emails through Rules. Instead of doing it that way (and risking overutilizing server resources when new emails were sent), I installed the SimpleNews module, and used a few of its hooks via Rules to schedule an email that will be sent in batches on cron runs.

Of course, once you get to the scale of hundreds or thousands of emails, you might start considering using an external resource such as Amazon SES. I'm guessing you're not quite to that level :-)

1

An article I just wrote about combining Rules and the Queue API, for Drupal 7 is the following: Using Rules and the Queue API to batch send mass mails.

1

You might be able to accomplish this using Rules and Views Bulk Operations. The following screencast might get you started: NodeOne talks Drupal: Rules + VBO, revisited!

1

Take a look at the Content Access Mail module (disclosure: I made it). Here are some details about it from its project page:

It provides an action for the Rules module that allows you to send rule-based emails to all users with permission to view a specific node.

It almost does what you want, so following on from @googletorp's comment about using hook_mail, this might give you a head start towards your own module.

0

I trust you can create a view (using the Views module) of the nodes (with their authors) for which you want to send such eMails. After you succeeded in creating such view, continue like so:

  1. Use Views bulk operations to enable bulk operations for each result in your view.
  2. Create a Rules Component which uses Rules action "Send a message". If you want, add 2 "variables" to this Rules Component, named something like "MsgSubject" and "MsgBody". By doing so, you can use those variables as "tokens" for constructing the actual Subject and Body of your message.
  3. Within your VBO settings, just execute this Rules Component. If you then use this VBO-view, you can specify the desired values for the variables used to create your Rules Component (like "MsgSubject" and "MsgBody"). So you avoid hardcoding the "Subject" and "Body" for the "Send a message" action (without those variables it would only allow you to send predefined messages). And this simply by using these variables of your Rules Component (to implement that "Subject" and "Body" of the message). That way, each time you use your VBO to send such messages, you can enter the desired "Subject" and "Body" for each of those messages.

For some other illustrations about using VBO in combination with Rules Components, refer to the answers to these questions:

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.