send an email notification to members of a particular role when a new product is created

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
greenitcompany's picture

Has anyone had any luck with creating a rule that can send an email notification to members of a particular role when a new product is created.

I've checked the standard and advance sets of rules and although you can seem to email when a particular trigger occurs, there does not seem to be the most appropriate action available from the list of optional actions. You only seem to be able to send an email to one recipient.

  1. Can I use Rules to lookout for the creation of new products?
  2. When a new product is created can i notify not just one user, but all users who have a particular role?

If Rules cannot do the above is there a modules that can?

I have tried Notify and this is a global module. It has no controls to allow you to just notify particular users or members of a given role.

I have also looked into using Triggers and Actions. However this also has a limited capability and again only allows the sending of a notification email to one recipient.

I would have though that this kind of requirement would be a key requirement for anyone looking to run a membership driven site with varying subscription offerings. This seems to also be what Drupal is excellent at providing but without this feature.

Any advice and help appreciated.

Adam

Comments

Drupal 6 or 7?

jasonawant's picture

Hi, are you using drupal and rules 6 or 7? I've done this in 6, and I'm fairly confident this can be down in 7. Jason.

Drupal 6.26

greenitcompany's picture

Hi Jason

Thanks for the swift response.

Drupal 6.26

Adam

Action: Send a mail to all users of a role

jasonawant's picture

Hi,

Rules is your answer. Look for the action "Send a mail to all users of a role".

Event: After saving new content
Condition: Content has type
Action: Send a mail to all users of a role

Jason.

Splendid

greenitcompany's picture

That works but alas i just get a message and no link to the node. But i may try setting up a spcific view that displays all products of the type i want to inform the specific users about and then add the link to the view page in the message being sent by the triggered rule. I think this may do it.

Although is there an easier way?

Thanks again,

Adam

Tokens?

jasonawant's picture

Hi,

You can surely use tokens in your message. Do you have the Token module installed and enabled.?

Look for the Token replacement patterns section in your action config page.

You can use something like [node:node-url] I think.

Jason.

Token usage

greenitcompany's picture

Hi Jason,

Would the token replacement pattern be placed in the email message field?

Thanks in advance,

Adam

Tokens

jasonawant's picture

Hi,

Yes, put the token in the message. Good luck! Jason.

PS. Some friendly advice: give yourself over to experimentation and try things out, test, fail, and then try something new!

If you figure out how to send

usmith's picture

If you figure out how to send a view, please post here!

I have been able to send information from a node- but caveat, I am on Drupal 7. I input the node id (or hard code it) and in a rules component action, I fetch enity by Id, using that node id. Then in another action to send an email, I use [entity-fetched:body] to get the contents of the body field of that node, and use that to enter into the email. This works as long as it is a normal text (or in this particular case) formatted text field. I tried using a body field with embedded PHP code to fetch a view (

<?php
echo views_embed_view(‘view_name’, $display_id = ‘view_display_name’) ;
?>
) and that did not work.

Anyway, hope this helps, and if anyone knows how to render a view into the body of an email message in Rules, please share your know-how!!

I am going to answer my own

usmith's picture

I am going to answer my own question. I found out today that there was a patch required for embed view to work. You need to look at this note- http://drupal.org/node/1471770- and apply the patch posted on May 25, 2012. After that I was able to use the following PHP code in an HTML email and a field on a node using the PHP format.

<?php
echo views_embed_view(‘machine_name_of view’, $display_id = ‘machine_name_of_view_display_name’) ;
?>

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: