I'm working on a Drupal project where users can post classified ads. These are simply nodes created using a custom content type.
After 3 months, we want the user who created the node to receive a reminder email. We also need this email to be sent only once.
We're using Rules to send the emails.
This seems simple enough, but the implementation has been very difficult.
Right now, I'm stuck at limiting the number of times the email is sent. I have spent considerable time and effort online trying to find the answer. I still haven't found a straightforward explanation for this task. The closest I've seen is on this forum, which is why I'm asking for your help. It would be greatly appreciated.
= The setup =
There is a "Classified Ad" content type. It includes an "Email" field, and a (hidden) "Email sent?" field.
The user creates a "Classified Ad" node.
Views lists every ad that is more than 3 months old. The View has a VBO field. It also lists the "Email sent?" and "Sticky" values.
The "Send email" Rule is activated when the Cron runs. It has no conditions. It currently has three actions:
Load a list of entity objects from a VBO View. (This loads my list of 3 month old ads.)
Loop. (Loads the VBO list.)
-- Send HTML e-mail. (Sends email to the "Email" field value).
That works. So far so good.
My idea from here would be to add an action in the loop which would change the value of the "Email sent?" field from 0 to 1. I would then filter my View to hide all nodes that have this value.
= The issue =
I can't make Rules loop through my View and change the field value. I know others have had comparable problems and I've tried to apply the suggested answers but I didn't have any success.
I have also tried changing the Sticky value, but no success there either. I can change the first VBO item (at least for some tests), but I can't make Rules loop through all the items to update my nodes.
I have tried various approaches. The latest and (it seems) most promising is to use the Views Rules module. I installed it, created my "Rules" display for my VBO list, and added the Views loop to my Rule.
From there I tested all the combinations of Actions and Data Selectors I could think of to change the field value, but still no success. There were many tests.
Adding a "Set a data value" action inside my Views Rule Loop using "field-email-sent" as Data selector seems the most logical, but then Rules asks for a second Data selector, which makes no sense. When switching to direct input mode, I have to pick a "Node identifier", which makes even less sense. Attempts with other Actions or Data selectors have yielded similar results.
So either my approach is wrong, or one/more of my parameters are wrong. Either way, I need help.
How do I make this work?