Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://www.gravityhelp.com/forums/topic/modufy-user-notification-email-based-on-dropdown-selection#post-66948
- // change the 110 here to your form ID
- add_action('gform_pre_submission_filter_110', 'add_provider_details');
- function add_provider_details($form) {
- // define three providers
- $providers = array(
- 0 => array(
- 'company' => 'Alcohol Monitoring Systems Corporate',
- 'first' => 'Murray',
- 'last' => 'Brooks',
- 'phone' => '303-917-5405',
- 'email' => 'mbrooks@alcoholmonitoring.com'
- ),
- 1 => array(
- 'company' => 'Reliant Monitoring Services',
- 'first' => 'Nate',
- 'last' => 'Gay',
- 'phone' => '919-754-9422',
- 'email' => 'nategay@reliantmanagement.com'
- ),
- 2 => array(
- 'company' => 'Tarheel Monitoring West',
- 'first' => 'David',
- 'last' => 'Collins',
- 'phone' => '704-253-1054',
- 'email' => 'scramxwestnc@gmail.com'
- ),
- );
- // define the provider ID for each county in the form
- $counties = array(
- 'Alamance' => 0,
- 'Alexander' => 0,
- 'Alleghany' => 0,
- 'Anson' => 1,
- 'Ashe' => 0,
- 'Avery' => 0,
- 'Beaufort' => 1,
- 'Bertie' => 1,
- 'Bladen' => 0,
- 'Brunswick' => 0,
- 'Buncombe' => 0,
- 'Burke' => 2,
- 'Cabarrus' => 0,
- 'Caldwell' => 2,
- 'Camden' => 0,
- 'Carteret' => 1,
- 'Caswell' => 1,
- 'Catawba' => 2,
- 'Chatham' => 1,
- 'Cherokee' => 0,
- 'Chowan' => 0,
- 'Clay' => 0,
- 'Cleveland' => 0,
- 'Columbus' => 0,
- 'Craven' => 1,
- 'Cumberland' => 1,
- 'Currituck' => 0,
- 'Dare' => 0,
- 'Davidson' => 0,
- 'Davie' => 0,
- 'Duplin' => 1,
- 'Durham' => 0,
- 'Edgecombe' => 1,
- 'Forsyth' => 0,
- 'Franklin' => 1,
- 'Gaston' => 0,
- 'Gates' => 0,
- 'Graham' => 0,
- 'Granville' => 1,
- 'Greene' => 1,
- 'Guilford' => 0,
- 'Halifax' => 1,
- 'Harnett' => 1,
- 'Haywood' => 0,
- 'Henderson' => 0,
- 'Hertford' => 1,
- 'Hoke' => 1,
- 'Hyde' => 1,
- 'Iredell' => 0,
- 'Jackson' => 0,
- 'Johnston' => 1,
- 'Jones' => 1,
- 'Lee' => 1,
- 'Lenoir' => 1,
- 'Lincoln' => 0,
- 'McDowell' => 0,
- 'Macon' => 0,
- 'Madison' => 0,
- 'Martin' => 1,
- 'Mecklenburg' => 0,
- 'Mitchell' => 0,
- 'Montgomery' => 1,
- 'Moore' => 1,
- 'Nash' => 1,
- 'NewHanover' => 0,
- 'Northampton' => 1,
- 'Onslow' => 1,
- 'Orange' => 1,
- 'Pamlico' => 1,
- 'Pasquotank' => 0,
- 'Pender' => 0,
- 'Perquimans' => 0,
- 'Person' => 1,
- 'Pitt' => 1,
- 'Polk' => 0,
- 'Randolph' => 1,
- 'Richmond' => 1,
- 'Robeson' => 1,
- 'Rockingham' => 0,
- 'Rowan' => 2,
- 'Rutherford' => 0,
- 'Sampson' => 1,
- 'Scotland' => 1,
- 'Stanly' => 1,
- 'Stokes' => 0,
- 'Surry' => 0,
- 'Swain' => 0,
- 'Transylvania' => 0,
- 'Tyrrell' => 1,
- 'Union' => 1,
- 'Vance' => 1,
- 'Wake' => 0,
- 'Warren' => 1,
- 'Washington' => 1,
- 'Watauga' => 0,
- 'Wayne' => 1,
- 'Wilkes' => 0,
- 'Wilson' => 1,
- 'Yadkin' => 0,
- 'Yancey' => 0
- );
- // define notification parts here
- $part_one = "<table id='backgroundTable' width='100%' border='0' cellspacing='0' cellpadding='0'><tbody><tr><td style='height: 100% !important; margin: 0 !important; padding: 0 !important; width: 100% !important;' align='center' valign='top'><!-- Body --><table id='templateBody' width='100%' border='0' cellspacing='0' cellpadding='20'><tbody><tr><td align='center' valign='top'><table width='560' border='0' cellspacing='0' cellpadding='0'><tbody><tr><td class='bodyContent' style='padding-bottom: 40px;' valign='top'><img id='headerImage campaign-icon' style='max-width: 560px;'src='http://alcoholmonitoring.com/site/designs/shared/images/logo-scramx.png' alt='' /><h1>SCRAMx Offender Referral Confirmation</h1><p>{Referring Officer Name (First):8.3} {Referring Officer Name (Last):8.6},</p><p>Success! Your referral information was submitted and has been receieved by the authorized SCRAMx service provider for <strong>{Referring County:2} County</strong>:</p>";
- $part_three = "<h2>Offender Information</h2><p>{Offender Name (First):14.3} {Offender Name (Last):14.6}<br /><strong>OPUS Number:</strong> {OPUS Number:15}</p></td></tr></tbody></table></td></tr></tbody></table><!-- Body --></td></tr></tbody></table>";
- // read the county from the form submission. It's in field #2 currently
- $county = rgpost('input_2');
- // determine the county ID from the country string that was submitted
- $countyID = $counties[$county];
- // retrieve provider information based on the county ID
- $providerCompany = $providers[$countyID]['company'];
- $providerFirst = $providers[$countyID]['first'];
- $providerLast = $providers[$countyID]['last'];
- $providerPhone = $providers[$countyID]['phone'];
- $providerEmail = $providers[$countyID]['email'];
- // concatenat all the provider information
- $providerInfo = "<h2>Provider Information</h2><p>Company Name: $providerCompany<br />Contact Name: $providerFirst $providerLast<br />Contact Phone: $providerPhone<br />Referral Email: <a href='mailto:$providerEmail' title='send an email'>$providerEmail</a><br /></p>";
- // concatenat all three parts of the notification
- $form['autoResponder']['message'] = $part_one . $providerInfo . $part_three;
- // return the $form object which will contain the user notification
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement