I'm working on a Drupal project where users can post classified ads. These are simply nodes created with the help of 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 once.
We use rules to send emails.
This sounds pretty simple, but the implementation has been very difficult.
At the moment, I am unable to limit the number of times the e-mail is sent. I have spent a lot of time and effort online trying to find the answer. I still have not found a simple explanation for this task. The closest I've seen is on this forum, that's why I'm asking for your help. This would be highly appreciated.
= The configuration =
There is a content type "Classified Ad". It includes an "Email" field and an "Email sent?" (Hidden) field.
The user creates a "classifieds" node.
Views lists all ads older than 3 months. The view has a VBO field. It also lists the "Email sent?" and "sticky" values.
The "Send Email" rule is enabled when Cron runs. There are no conditions. It currently has three actions:
Loads a list of entity objects from a VBO view. (This loads my list of 3 month announcements.)
Loop. (Load the VBO list.)
– Send an HTML email. (Sends an e-mail to the value of the "Email" field).
It works. Until here everything is fine.
My idea here would be to add an action in the loop that would change the value of "Email Sent?" field from 0 to 1. I would then filter my view to hide all the nodes that have this value.
= The problem =
I can not make rules run through my view and change the value of the field. I know others have had similar problems and tried to apply the suggested answers, but I failed.
I've also tried to change the value of Sticky, but without success there either. I can change the first element of VBO (at least for some tests), but I can not make rules run through all elements to update my nodes.
I have tried different approaches. The most recent and (it seems) most promising is to use the Views Rules module. I installed it, created my "Rules" view for my VBO list and added the Views loop to my rule.
From there, I tested all the combinations of actions and data selectors that I could think of to change the value of the field, but still without success. There were a lot of tests.
Adding a "Set Data Value" action in my view rule loop with the help of "field-email-sent" as the data selector seems the most logical, but Rules asks for a second data selector, which makes no sense. When I switch to direct input mode, I have to choose a "node identifier", which makes even less sense. Attempts with other actions or data selectors yielded similar results.
So, either my approach is wrong, or one or more of my settings are wrong. Anyway, I need help.
How can I do this job?