Drupal 7 Rules: Send E-mail to User Referenced by NID After Saving Content

| Drupal Development | 8 seen

A time ago I started to work on a custom Drupal powered translation management system, unfortunately as I didn't have much spare time and actually there are really great alternatives (paid) out there - I decided to postpone this project.

Despite the project wasn't actively developed, it was though running a separate Linode VPS for it (which costs money), I decided to delete this instance to save money, but before that, I decided to keep at least one interesting feature I figured out - how to send e-mail to the assigned user (not user but node reference, in terms of Drupal) , after saving new project (node)

I had 2 content types - Translators and Projects, in the Projects content type I created a custom field ( field-assign-to) where with the help of node references I referenced username from Translators content type

Node Reference in Drupal 7

Node Reference in Drupal 7

Learn more How To Reference Nodes in Drupal 8 + Views Relationships Display

Actually, a couple of years ago I was working on a similar assignment but less complex, see: ​ Drupal Rules - How To Configure Journalist and Editor roles to Unpublish/Publish Content

Here I will paste plain Drupal 7 Rules export (working)

{ "rules_after_saving_new_project_send_email" : {
    "LABEL" : "After saving new Project Send Email",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert--projects" : { "bundle" : "projects" } },
    "IF" : [
      { "entity_is_of_bundle" : {
          "entity" : [ "node:field-assign-to" ],
          "type" : "node",
          "bundle" : { "value" : { "translators" : "translators" } }
        }
      }
    ],
    "DO" : [
      { "mail" : {
          "to" : [ "node:field-assign-to:field-e-mail" ],
          "subject" : "[node:title]",
          "message" : "[node:body]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Works for Drupal 7

Add new comment