I have created a date field for all users (in Drupal 7). This date is the end of the user's subscription. When the date of this field is passed, I want to send a mail to the user to tell him he can subscribe again (to access our website).

So, I have created a view with a display rules (with module views rules). I have listed all users who have the field date not empty and filter to have only date passed. I have 2 fields in this view (user name and date). I have edited field info and enable my 2 fields (Data type : user and data type : date) :

enter image description here

After, I have created a rule wich react on the event "Cron maintenance tasks are performed" and created a view loop on the display rules of my view. In the loop i have added 2 actions : change the date value to exit the user from the view, and send a mail to this user :

enter image description here

When I Launch the cron, nothing happen. The date is not changed, and the mail is not send. I don't know what configuration I have forgot. Do you have an idea please ?

Thank you for help me.

My rule in export format:

{ "rules_relance_e_mail" : {
"LABEL" : "Relance e-mail",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "cron" : [] },
"DO" : [
  { "VIEW LOOP" : {
      "VIEW" : "dates_de_relances",
      "DISPLAY" : "views_rules_1",
      "ROW VARIABLES" : {
        "name" : { "name" : "Nom" },
        "field_date_de_relance" : { "field_date_de_relance" : "Date de relance" }
      "DO" : [
        { "data_set" : { "data" : [ "field-date-de-relance" ], "value" : "+1 year" } },
        { "mail" : {
            "to" : [ "name:mail" ],
            "subject" : "Test relance",
            "message" : "Test mail",
            "language" : [ "name:language" ]
  • Please include an export of your Rule (created using the Rules UI), to provide "all" the details of your current rule (the screenprint doesn't show everything to pinpoint the reason why nothing seems to happen ...). Commented Apr 20, 2017 at 8:55
  • Thank you Pierre for your answer. I have added my rule export to the post. (It is simple, I have probably forgotten parameters) :
    – David CKW
    Commented Apr 20, 2017 at 9:00

1 Answer 1


Part 1: Sending an eMail

Your view needs refinement ...You seem to have 1 Views result (row) for each user to be eMailed, which is OK. But that view must have fields (columns) for each of the fields that you want to use in your Rules Action to create your eMail. So the [name:mail] and [name:language] in your Rules Action should be replaced by some column in your view to make those available. For that you might have to also add a "relationship" in your view to the "user object" (so that eg the eMail ID becomes available).

Have a look at these answers for some more details:

Part 2: Saving the changed date

You may have to add an extra Rules Action to "save an entity", because you need to remind the Rules module to also save the date you've updated.

  • Ok Thank you very much. There is progress. I add the field user email as a column in my view and configure rules to send e-mail to this field. It works (finally no need relationship in my view) and the mail is sent. But the change of the value of my date doesn't work. I saw it may have problem with the action "set a data value" and a field date. I search now how to change this date, wich is well present in a column of my view.
    – David CKW
    Commented Apr 20, 2017 at 10:00
  • @DavidCKW check the part 2 that I added ... Let me know if that helps to complete your "puzzle" ... Commented Apr 20, 2017 at 10:06
  • Could you tell me how add an extra rules action to "save entity" please ? If I add action "save entity" in the views loop, I have only "site:" in the data selector (and not my fields). What is the procedure to do what you advise to me ?
    – David CKW
    Commented Apr 20, 2017 at 11:47
  • @DavidCKW I think you should have split this question in 2 separate questions, but maybe this extra tip will help to get it all to work: also pass the "uid" of the user being processed (by adding an extra column for uid in your view). Then add, as the first action inside the views loop a "Fetch entity by id" (to make the user related data availabe). If this tip doesn't help, please consider splitting that part of your question to a new question (as a followup question), and hopefully mark this answer as "accepted" then also. OK? Commented Apr 20, 2017 at 12:07
  • thanks. I always have problems for update the user field date, but a mail is sent. I have vote for your answer.
    – David CKW
    Commented Apr 20, 2017 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.