1

I have created one group using the Group module. In that group I have 1 node type and 3 members.

I want to send a confirmation email to group members whenever I add new nodes of that node type. How can I do that?

Notes:

3

Only using the Groups module

The Group module is an upcoming alternative for the Organic Groups module for D7, for which right now there is only a beta version available. Remark: the Groups, Communities and Co module (= GCC) is yet another alternative (with an official release for D7).

The Group module appears to be an interesting alternative, though it doesn't come with a lot (if any) documentation so far.

The best docu available, I think, is to read its sources. In doing so, I learned that its Group Invite submodule "Allows group members to invite people into their group", which will trigger appropriate eMails. Of course, that implies that the user who wants to send these invites, is already a group member. But this "function" is not really what you seem to be looking for (as per your additional comment to my answer here).

Instead, you want to "Send an email to group members of particular group when a new node is created". To do so, I'd narrow down your question to 3 sub-questions (= tasks), and try to implement this using the Rules module, as further detailed below ...

Also using the Rules module

Rules Event

That's easy, more or less out-of-the-Rule-box: When a new node is created.

Rules Condition

This is your Challenge 1: Only if "Node type of the created node belongs to some group".

Rules Action

Create a Rules "component" to send an eMail (anybody can do that, right?). Here is a typical sample of such component (in Rules export format, just import it in your own environment via copy-paste):

{ "rules_send_email_notification" : {
    "LABEL" : "Send eMail notification",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
    "ACTION SET" : [
      { "mail" : {
          "to" : [ "user-to-notify:mail" ],
          "subject" : "New node was added",
          "message" : "New node was added for content type ...",
          "from" : "[site:mail]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Obviously, the Subject and Content of the eMail may need review / tuning, while you might also want to use some other From eMail ID.

This is your Challenge 2: construct the "To" content of such eMail, i.e. all eMail IDs of all members of the group. That is what the value should be for user-to-notify:mail in the Rules component shown above.

Write your custom Rule(s)

To address the above Challenges 1 and 2, you could write your custom module, in which you basically would do 2 things:

If you're looking for more Rules related coding samples, you may want to look at the Rules URL Argument module. Here is a quote about it (from its project page, bold markup added here):

... provides two rules conditions based on URL arguments:

  • check if a URL argument is present.
  • compare the value of an URL argument.

It also provides an action that makes the value of an URL argument available as new variable to Rules.

The newly provided Rules actions and conditions can be found under the "URL Argument" conditions and actions groups in the rule configuration interface.

For an example of how to use it, refer to Comment # 3 in issue # 1686360 which is about "Pass an amount to the url, ie; site/content/node-title?amount=10 or /node-title?=amount:10".

  • how can i send email to group members of particular group on creation of new node ? – Sonvir Choudhary Aug 25 '15 at 11:48
  • @Pierre.Vriens Thank you for this tutorial. But I can not create my rule. I wish that when a group is flag, an email is sent to all members of that group. How to do this ? – user54067 Oct 16 '16 at 23:52
  • @Pierre.Vriens I just post a new question. thank you in advance for your help drupal.stackexchange.com/questions/219263/… – user54067 Oct 31 '16 at 10:10
  • @Pierre.Vriens I deleted the last sentence. But I do not understand (with "poorly"). – user54067 Oct 31 '16 at 12:44
  • @Mathieu, ok, merci for that. FYI: to me that phrase looked like "the integration of Group with rules, views, and permissions is terrible". That's probably (hopefully!) NOT what you wanted to say/write. If you want, add an extra comment here to better explain what you wanted to say in that phrase. I'll then try to help you to find a better description for it, ok? PS: maybe something like "I find it difficult to understand how Group integrates with rules, views and permissions"? – Pierre.Vriens Oct 31 '16 at 12:49
1

Install and enable Rules module. Now you can see there is a already created inactive rule at admin/config/workflow/rules path. Just enable this rule and you are done.

  • thanx for your comment. I tried that also, but this is not a solution for my issue – Sonvir Choudhary Aug 25 '15 at 11:19
  • @SonvirChoudhary, Sorry my fault, above solution will work for Oraganic Groups module. – Yatendra Singh Aug 25 '15 at 12:25

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.