There doesn't seem to be a "custom ruleset" module on Drupal.org, but I'd simply use the Rules module, together with the Webform Rules module, as further explained below.
Step 1 - Create a basic eMail about the submitted Webform
Have a look at this example rule (in Rules export format):
{ "rules_process_submitted_webform" : {
"LABEL" : "Process submitted webform",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"OWNER" : "rules",
"REQUIRES" : [ "rules", "webform_rules" ],
"ON" : { "webform_rules_submit" : [] },
"IF" : [
{ "data_is" : { "data" : [ "form-id" ], "value" : "2" } },
{ "user_has_role" : {
"account" : [ "site:current-user" ],
"roles" : { "value" : { "2" : "2" } }
}
}
],
"DO" : [
{ "mail" : {
"to" : "[site:mail]",
"subject" : "A new webform submission has occured",
"message" : "A new webform submission has occured (with form-id \u0022[form-id:value]\u0022). It was submitted by the user with id = [user:id], name = [user:name] and eMail Id = [user:mail] ...",
"language" : [ "" ]
}
}
]
}
}
Some details about the above rule:
- Rules Event: After a webform has been submitted
- Rules Conditions:
- Form-id has value "
2
" (change to whatever form-id to fit your case).
- User submitting the form is logged in.
- Rules Action: Sent an eMail.
Not sure if it is the case for you, but if the user who submitted the form is authenticated (not anonymous), then you do already have access to a limited set of tokens related to the user who submitted the webform, such as [user:id]
, [user:name]
and [user:mail]
. If the user is anonymous, just omit that condition, and don't refer to those tokens in the eMail being created.
Step 2 - Include data from the submitted Webform data in your eMail
You do have access to all labels and all values of any field of a Webform, ie:
[data:MachineFieldName-title]
contains the Label of a field with machine name MachineFieldName.
[data:MachineFieldName-value]
contains the Value of a field with machine name MachineFieldName
For way more details on this, and a prototype rule about this, refer to the answer to "How to create a node from a Webform using rules?":
- the 1st attempt relates to using "Entity has field" (which doesn't work for Webform).
- the 2nd attempt explains what to do in case of Webform.
And while the above is a good start, it may still not be sufficient to achieve your goal. I.e. if you want to use specific data from the submitted webform. However, 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:SomeField-value-raw]
(and with an appropriate data type). I'm assuming a field in your webform has a machine name like SomeField
(adapt to fit your machine name).
- In your subsequent Rules Actions you can refer to the value of this variable you just added (that's the clue!).
Step 3 - Cover all possible variations of the Webform data
To make this work for each of the 4 (or 5?) conferences, you basically have 2 options:
- Duplicate this rule for each possible form id (or form component value if all conferences are covered via a single form) you want to process this way. E.g 1 such rule for each conference.
- Use the Conditional Rules module if you want to have a single (consolidated) rule for all conferences to be processed.
Here is an example rule (in Rules export format), which uses the Conditional Rules module:
{ "rules_process_submitted_webform_based_on_a_component_value" : {
"LABEL" : "Process submitted webform based on a component value",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_conditional", "webform_rules" ],
"ON" : { "webform_rules_submit" : [] },
"IF" : [
{ "data_is" : { "data" : [ "form-id" ], "value" : "2" } }
],
"DO" : [
{ "variable_add" : {
"USING" : { "type" : "text", "value" : "[data:somefield-value-raw]" },
"PROVIDE" : { "variable_added" : { "submitted_form_component_value" : "Submitted form component value" } }
}
},
{ "SWITCH" : {
"USING" : { "data" : [ "submitted-form-component-value" ] },
"DO" : [
{ "CASE" : {
"USING" : { "value" : "1" },
"DO" : [ { "drupal_message" : { "message" : "Webform Option 1 was selected" } } ]
}
},
{ "CASE" : {
"USING" : { "value" : "2" },
"DO" : [ { "drupal_message" : { "message" : "Webform Option 2 was selected" } } ]
}
},
{ "CASE" : {
"USING" : { "value" : "3" },
"DO" : [ { "drupal_message" : { "message" : "Webform Option 3 was selected" } } ]
}
},
{ "DEFAULT CASE" : [
{ "drupal_message" : { "message" : "Webform Option selected was different from 1, 2 and 3" } }
]
}
]
}
}
]
}
}
Some details about the above rule:
- Rules Event: After a webform has been submitted
- Rules Condition: Form-id has value "
2
" (change to whatever form-id to fit your case).
Rules Actions:
- Add an extra Rules Action to
Add a variable
, with a value assigned to it equal to your [data:SomeField-value-raw]
(and with an appropriate data type). I'm assuming a field in your webform has a machine name like SomeField
(adapt to fit your machine name).
- Show a message on the site (depending on the value of the variable that was added via the prior Rules Action).
What is left to do to further tune the above Rules example to fit your needs:
- Replace the "Show a message on a site" by an appropriate eMail to be created (for each "case").
- And for each of those eMails just indicate which eMail Ids should receive that eMail.
Voilà
PS: forget about your "custom ruleset module", no more need for it to solve this challenge.