Simplenews condition results in double email

by Kristoffer Rom   Last Updated December 05, 2017 22:07 PM

I've got a simple rule sending a notification email to site admin on the event 'A user has been subscribed'.

I'm however getting 2 emails on a signup. Any idea why and how to fix so the admin only gets notified once on each signup?

SimpleNews Version: 7.x-1.1 Core Version: 7.39



Answers 2


@Kristoffer Rom, I've just tested and I've got the same duplication.
So, I suggest you create such notification rule based on:

  • "After saving new user account" event.
  • "Send mail" action from "System" actions group.
jvb
jvb
December 07, 2015 15:20 PM

Understanding what's happening

Your question seems like a variation of the question 'Why is my rule that reacts on event "After updating an existing user account" firing twice?'. The accepted answer in that question might help to understand your issue (what's causing it) also, ie:

some other module code is calling a user_save on hook_user_update triggering the rules event a second time.

If I was to debug this, I'd disable all contributed modules (except "Rules" and "Entity API") to check if it's indeed a contributed module (I don't expect it to be core). And then re-enable the contributed modules one by one until the issue comes back. As soon as it comes back, you pinpointed the contributed module causing the issue, and you can start working on a possible remedy for that.

Workaround 1

That question also has another answer with a very interesting workaround, with an image which looks like so (a picture is worth more then 1000 words):

enter image description here

Workaround 2

Another workaround to prevent this issue from happening, is to improve your existing rule to make it similar to the rule included in my answer to "How to implement a Rules Condition like [account:last-login] = never?". More specifically:

  • Add a Rules Condition like: User does NOT (!!!) have a role with role id = "4".
  • Add a Rules Action like: Grant User the role with role id = "4".

So this improvement of your rule will check if the user does not yet have some (designated) role with role id = "4" (adapt to whatever role id that fits your case). If that's the case, then the user is granted that role. With this improvement to your existing rule, this is what will happen:

  • The 1st time your Rules Actions will still be performed (and grants the designated role).
  • the 2nd time not ALL of your Rules Conditions will be satisfied (since the designated role was granted before), and therefor your Rules Actions will no longer be performed.
Pierre.Vriens
Pierre.Vriens
December 05, 2017 21:10 PM

Related Questions




Send html-Mail to new simplenews subscriber

Updated May 11, 2016 08:03 AM

How to get a list of entities programmatically?

Updated August 17, 2017 15:07 PM