HI,

I use the Rules module and the Organic Group module.

I want to notificate by email all members of a group when a new post is published in the group. Is it actually possible to make that ? Or not ?

It would be an alternative to the existing Action Rule : "Send email to a Role".

Thanks for your help !

CommentFileSizeAuthor
#16 drupal-example.jpg78.98 KBpaultrotter50
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mitchell’s picture

Title: Send an email to all members of a (organic) group when post is published in the group » Send an email to all members of a (organic) group
Project: Rules » Organic groups
Version: 6.x-1.2 » 6.x-2.x-dev
Component: Features integration » OG actions

Organic Groups already has a condition for 'Content is a group post' but there isn't yet an action for sending an email to group members. Without that action, you could use views and a custom php action like what's in #371728: Load Multiple Nodes to perform actions on them, but that isn't as pretty a solution.

vstmusic’s picture

It's a little tricky.

Is it possible to implement this feature ?

vstmusic’s picture

I must use a php code to select the emails of members of an organic group, with view module ?

I can't make that alone. can you help me ?

brisath’s picture

Subscribing. I would like a feature for using Rules to send tokenized emails to each group member (from the group where a post was placed).

amitaibu’s picture

Status: Active » Closed (won't fix)

Looping over a list can only be done in Rules (i.e. for Drupal 7). You will need custom code to achieve this in D6.

mitchell’s picture

vstmusic’s picture

thanks for this link. I have tryed this tutorial but it actually sends blank email. I don't understand why.

bryancasler’s picture

subscribe

vstmusic’s picture

Now it works ! The author of the code have edited his code !

Very useful !

brisath’s picture

Great details in that description in #6. However, I'm hesitant to try the custom module method for fear of minor problems like #7 and updates that might make it incompatible. For me, this feature would be useful it if was part of the OG package.

vstmusic’s picture

I confirm it's a very useful module ! I use it since 1 month an NO PROBLEM !

jamsilver’s picture

For those of us still searching for something simple but effective, I just stumbled across http://drupal.org/project/og_email_blast which just does what everyone wants =)

flaviovs’s picture

For those of us still searching for something simple but effective, I just stumbled across http://drupal.org/project/og_email_blast which just does what everyone wants =)

Not saying that the aforementioned module isn't useful, but one should notice that it is D7 only, and this post is (so far) about D6.

Yonik’s picture

Issue summary: View changes

I've the same problem but I've D7. Any idea?

Thanks.

flaviovs’s picture

@Yonik, for D7, see amitaibu's comment #5.

Basically, Rules + Views may be used to implement this.

E.g. create a view that list users subscribed to a group (do not forget to check for active membership, unblocked account, etc.), and filter the view by group (node) ID using a contextual filter. Next, create a rule that react to a new post on a group. Then, using Rules Bonus Pack or View Rules, loop over your view (group nid being passed as argument) to send emails or maybe do other fancy things with each member.

Notice that this may work well only for small groups, but you may encounter performance and/or memory problems with large groups.

paultrotter50’s picture

FileSize
78.98 KB

For anyone who is looking here for the Drupal 7 method this is quite straightforward with rules and a loop. See screenshot

vstmusic’s picture

How to select the ACTIVE users of a group, with the paultrotter50 method ?

Thanks !

carsato’s picture

Hello.

I managed to solve it using "og_is_member()" using php in the "to:" field.

I load a members of the group.
I load the node of the group ($club)
I add an action (send email)
In the "to:" field, with php I set:

<?php
$emails_to_send = array();
foreach($group_members as $member){
  if(og_is_member('node',$club->nid, 'user', $member)){
    $emails_to_send[] = ($member->mail);
  }
}
print implode(', ',$emails_to_send);
?>
vstmusic’s picture

UP : How to select the ACTIVE users of a group, with the paultrotter50 method ?
With this method, inactive users receive email notifications. It's a problem.

simon_j_nichols’s picture

Pauls method should work, the interface for og_is_member is

og_is_member($group_type, $gid, $entity_type = 'user', $entity = NULL, $states = array(OG_STATE_ACTIVE))

so only active members should be selected by default. I think the embedded php carsato used is considered bad form (but hey if it works!!! and you avoid using a loop to sometimes send identical mail to each member individually). I actually built a new action to get all members and mail them together by populating the to: field with a list, to do essentially the same as carsato but within the rules framework, so if you have a little php experience that's another option.

vstmusic’s picture

Sorry, by using the terms "the active users of a group", I mean the users who are not blocked in the user/edit form. In fact, with the paultrotter50 solution (#16), the blocked users receive notifications of the OG groups in which they have subscribed. Do you understand ? (sorry for my bad english...)