1

I need to send an email notification to the node editor (reviewer/moderator) when an admin changes a (custom) field.

I've added the list of editors as a field in node form.

The nodes will be created by users and unpublished by default.

The nodes will be assigned to editor for review by admin, the editor should be able to view records assigned to the editor.

When admin assigns a node to editor, the editor should be notified by email.

How can I notify editors when they are assigned a node by admin?

Rules requires data comparison, conditions to trigger action. But I need to trigger action when a particular field gets changed.

I would like to use Drupal hooks like hook_node_update, by that way we can get the email id of the editor (in my scenario) and notify the editor.

Programmatically where and how I use hook_node_update() to achieve this? Or can the Rules module be used? If so please explain in detail how to create a rule for this.

  • Hi Pierre, the content will be assigned to editor for review by admin, the editor should be able to view records assigned to him. When admn assigns a node to editor, editor should be notified by email. I've added the list of editors as a field in node form. How can I notify editors when they are assigned with node by admin – Lakshmanan PHP Feb 3 '16 at 9:21
0

Check notification email link my point is enough to post in comment box so i am posted here

| improve this answer | |
0

Using the Rules module to answer your question seems to me like the most straight forward solution.

Here is a rule (in Rules export format), which does exactly what your question is about:

{ "rules_email_reviewer_after_admin_updates_custom_field" : {
    "LABEL" : "eMail reviewer after admin updates custom field",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_update" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "3" : "3" } }
        }
      },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_free_format_text" } },
      { "NOT data_is" : {
          "data" : [ "node-unchanged:field-free-format-text" ],
          "value" : [ "node:field-free-format-text" ]
        }
      },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_assigned_user" } }
    ],
    "DO" : [
      { "mail" : {
          "to" : [ "node:field-assigned-user:mail" ],
          "subject" : "Node with id=[node:nid] is waiting your review",
          "message" : "An administrator assigned the Node with id=[node:nid] to you, please review it.",
          "from" : [ "site:current-user:mail" ],
          "language" : [ "" ]
        }
      },
      { "drupal_message" : { "message" : "User [node:field-assigned-user:name] will be notified by eMail that you just assigned this node to that user (waiting review)." } }
    ]
  }
}

This rule is based on these assumptions:

  • The admin who performs the change, is a user with role id = 3 (adapt to fit your needs).
  • The field with machine name field_free_format_text is a single value field, and reflects the custom field that is changed (adapt the machine name to fit your needs, pick whatever type for this field that fits your needs).
  • The field with machine name field_assigned_user is an entity reference field to a user entity, defined as required, and with a single value (adapt the machine name to fit your needs).

Some more details about the above rule:

  • The Rules Actions will only be performed if a user with role "administrator" updates a node, and actually also updates the value of the field_free_format_text field.
  • This Rule will perform these Rules Actions:
    • Send an eMail (1) From the eMail Id of the administrator (2) To the eMail Id of the user referenced via the field_assigned_user field, and (3) with an eMail Body which looks similar to this example: An administrator assigned the Node with id=71 to you, please review it.
    • Show an informational message to the administrator, which looks similar to this example: User Pierre.Vriens will be notified by eMail that you just assigned this node to that user (waiting review).
| improve this answer | |

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.