Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // v 0.4 Revised January 10, 2013
- // http://www.gravityhelp.com/forums/topic/change-option-value?replies=19#post-103945
- // this code will apply to form 1 only
- add_action('gform_pre_submission_filter_1', 'strip_pricing_again');
- function strip_pricing_again($form) {
- $field_pair = array('input_1' => 'input_57', // envia el Desayuno elegido al ZOHO
- 'input_2' => 'input_58', // envia el Nº de personas al ZOHO
- 'input_55' => 'input_59', // envia los extras al ZOHO
- 'input_27' => 'input_60', // envia forma de pago al ZOHO
- 'input_52' => 'input_61'); // envia la población al ZOHO
- // define the separator one time
- $needle = '|';
- // loop through all the field pairs
- // the unmodified value is stored in $_POST[$original]
- // and after modification it will be assigned to $_POST[$hidden]
- foreach ($field_pair as $original => $hidden) {
- // deal with field 55 differently because it is checkboxes
- if($original == 'input_55') {
- // start with an empty $result string
- $result = '';
- // there are 23 checkboxes but _10 and _20 are skipped, so we need to count to 25
- for($i=1; $i <= 25; $i++) {
- // each checkbox choice
- $choice = $original . "_$i";
- // make sure the choice was submitted before checking the value
- if(isset($_POST[$choice])) {
- $haystack = $_POST[$choice];
- $result .= substr($haystack, 0, strpos($haystack, $needle)) . '; ';
- }
- }
- // assign the result string to the hidden field 60
- // trim off the trailing semicolon and space first
- $_POST[$hidden] = substr($result, 0, (strlen($result)-2));
- }
- else {
- $haystack = $_POST[$original];
- $result = substr($haystack, 0, strpos($haystack, $needle));
- $_POST[$hidden] = $result;
- }
- }
- // return the form
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement