Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.gravityhelp.com/forums/topic/help-with-conditional-routing
- // change the 53 here to your form ID
- add_filter('gform_pre_submission_filter_53', 'add_bcc');
- function add_bcc($form){
- // the array indexes here are the values of the input select boxes. View source of the form to see the actual IDs
- $addresses = array(
- 1 => 'store1a@example.com,store1b@example.com',
- 2 => 'store2a@example.com,store2b@example.com',
- 3 => 'store3a@example.com,store3b@example.com',
- 4 => 'store4a@example.com,store4b@example.com',
- 5 => 'store5a@example.com,store5b@example.com',
- 6 => 'store6a@example.com,store6b@example.com',
- 7 => 'store7a@example.com,store7b@example.com',
- 8 => 'store8a@example.com,store8b@example.com',
- 9 => 'store9a@example.com,store9b@example.com',
- 11 => 'store10a@example.com,store10b@example.com',
- 12 => 'store11a@example.com,store11b@example.com',
- 13 => 'store12a@example.com,store12b@example.com',
- 14 => 'store13a@example.com,store13b@example.com',
- 15 => 'store14a@example.com,store14b@example.com',
- 16 => 'store15a@example.com,store15b@example.com',
- 17 => 'store16a@example.com,store16b@example.com',
- 18 => 'store17a@example.com,store17b@example.com',
- 19 => 'store18a@example.com,store18b@example.com',
- 21 => 'store19a@example.com,store19b@example.com',
- 22 => 'store20a@example.com,store20b@example.com',
- 22 => 'store21a@example.com,store21b@example.com',
- 24 => 'store22a@example.com,store22b@example.com',
- 24 => 'store23a@example.com,store23b@example.com',
- 25 => 'store24a@example.com,store24b@example.com',
- 26 => 'store25a@example.com,store25b@example.com',
- 27 => 'store26a@example.com,store26b@example.com',
- 28 => 'store27a@example.com,store27b@example.com',
- 29 => 'store28a@example.com,store28b@example.com',
- 31 => 'store29a@example.com,store29b@example.com',
- 32 => 'store30a@example.com,store30b@example.com'
- );
- // my form uses input_1 for the select box. Your form may be different. Change it here is necessary
- $input_prefix = 'input_1_';
- // clear out any BCC notifications from the form builder
- $bcc = '';
- // loop through 30 fields to see if we need to send more notifications
- for ($i=1; $i<=30; $i++) {
- // be careful: Gravity Forms avoids numbering inputs with numbers ending in zero
- $input_field = $input_prefix . $i;
- // Check the form submission for the select box. If there is a value in $input_field, then add the addresses for that selection to the bcc list
- // rgpost is a safe way of accessing the $_POST values
- if (rgpost($input_field)) {
- $bcc .= $addresses[$i] . ','; // we'll strip off this last comma later
- }
- }
- // remove the trailing comma is there is one
- $form['notification']['bcc'] = rtrim($bcc, ',');
- // return the modified form object
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement