How to add notifications of subscriptions in Simplenews

Last updated on
10 September 2021

Drupal 8

Requirements:

Optional requirements:

  • Add a new role for the people you want to be notified. Alternatively, you will be able to choose any role, such as the administrator role, or define a specific list of email addresses to receive the notifications.

Instructions:

  1. Go to /admin/config/workflow/rules
  2. Click "Add reaction rule"
  3. Under the event "Event Selection" fieldset, in the "React on event" field, select "After saving a new simplenews subscriber of type Simplenews subscriber"
  4. After the "Restrict by type" field appears, select "Simplenews subscriber"
  5. Enter value in the Label field (e.g. "New newsletter subscriber"), and optionally add Tags and a Description
  6. Click "Save"
  7. On the next page, under "Actions" click "Add action"
  8. On the next page, under "Action", in the "System" group, select either "Send email" or "Send email to all users of a role" depending on your requirements
  9. Click "Continue"
  10. Enter either the email address(es) or role(s) to receive the notifications, one value per line, in the "Send to" field.
  11. In the Subject field enter a value for the email subject line such as "New subscriber on example.com"
  12. In the Message field enter a value such as "New subscriber email: {{simplenews_subscriber.mail.value}}"
  13. For other options, click "Switch to data selection", clear the "Data selector" view, and drill down to the value you need, typing simplenews_subscriber.. Once you have found your value, click "Switch to direct input mode" to switch back.
  14. Click "Save"

Next time someone subscribes you will get an email.

NOTE: as of 10 September 2021, this patch from this comment (or the dev version of the Rules module) is needed so that rules doesn't break the block visibility options: https://www.drupal.org/project/rules/issues/2927132#comment-13761341.

Drupal 7

For this to work you have to have:

  • Rules Module enabled
  • and Rules UI enabled (this comes with rules)
  • and simplenews rules enabled (this comes with simplenews)

After that you may want to add a new role for the people you want to be notified, but you can just choose any role like the administrator role.

  1. Go to [[yoursite]]/admin/config/workflow/rules and add a new rule. Give it a name, then choose "A user has been subscribed " from the simplenews events and set that for "React on event". And save it
  2. Add an action for this rule, choose "send mail for all users in a role". And choose the role you want to be notified
  3. Under subject add something like: New Subscription from <?php echo $mail; ?> for simplenews category <?php echo $tid; ?>
  4. Under message add something like: A new subscriber with the email <?php echo $mail; ?> for the simplenews category <?php echo $tid; ?> has been added for your site <?php echo $site; ?>. Be happy.
  5. save

Next time someone subscribes you will get an email. Now go and do the same for unsubscribe. Remember to use the event "A user has been unsubscribed" and use the proper wording in the email fields. This should do the trick.

You might be able to exchange the embedded php code with tokens, but this depends on the modules you have enabled in your installation.

Help improve this page

Page status: No known problems

You can: