0

This an export of my rule

{ "rules_webform_to_simplenews" : {
    "LABEL" : "Webform to simplenews",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "webform_rules", "rules", "simplenews_rules" ],
    "ON" : { "webform_rules_submit" : [] },
    "IF" : [
      { "webform_has_id" : {
          "form_id" : "webform-client-form-113",
          "selected_webform" : { "value" : {
              "webform-client-form-27" : "webform-client-form-27",
              "webform-client-form-113" : "webform-client-form-113"
            }
          }
        }
      }
    ],
    "DO" : [
      { "simplenews_rules_action_subscribe" : { "mail" : "[data:e_mail-value]", "tid" : "211", "confirmation" : "2" } }
    ]
  }
}

When a webform is submitted, the e-mailadres is added to the newsletter-subscriptions. But there should be an extra condition that the submitter agrees the subscribing by checking a select-option on the webform.

when i use the data-selector data:newsletter-value or data:newsletter-key for parmeter, it is refused.

  • what do you mean by "it is refused"? what error message do you get? – longboardnode May 4 '17 at 22:09
  • i' having the next-error: "Data selector data:newsletter-value for parameter data is invalid." – jimi May 11 '17 at 19:13
  • does it show this data selector as available in the replacement patterns section in the rule? – longboardnode May 11 '17 at 22:19
  • no, it isn't in the patterns – jimi May 15 '17 at 19:42
  • any feedback about my answer? – Pierre.Vriens Jan 24 '18 at 12:03
0

You can use a technique similar to what is described in my answer to "How to do a data comparison to submitted webform data when using the Rules module?". For short:

  • Add an extra Rules Action to Add a variable, with a value assigned to it equal to your [data:newsletter-value-raw] (assuming newsletter is the form component containing your select-option) and with a data type which equals the data type of your Webform component. In your subsequent Rules Actions you can refer to the value of this variable you just added (that's the clue!).
  • Use the Conditional Rules module to perform a data comparison. In this case to check the value of your select-option. If so, and only then, perform your Rules Action to add the email address as a subscriber.

PS: Instead of using the Conditional Rules module, you could also rework the Rules Action to performing Rules Components (in which you add the appropriate Rules Conditions), so that you don't need this extra module. For more details on that, refer to the answer to "What's the alternative to using the Conditional Rules module?".

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.