SHOW:
|
|
- or go back to the newest paste.
| 1 | - | // v 0.3 Revised January 9, 2013 |
| 1 | + | // v 0.4 Revised January 10, 2013 |
| 2 | // http://www.gravityhelp.com/forums/topic/change-option-value?replies=19#post-103945 | |
| 3 | // this code will apply to form 1 only | |
| 4 | - | add_action('gform_pre_submission_filter_260', 'strip_pricing_again');
|
| 4 | + | add_action('gform_pre_submission_filter_1', 'strip_pricing_again');
|
| 5 | function strip_pricing_again($form) {
| |
| 6 | - | $field_pair = array('input_1' => 'input_57', // envia el Desayuno elegido al ZOHO
|
| 6 | + | $field_pair = array('input_1' => 'input_57', // envia el Desayuno elegido al ZOHO
|
| 7 | - | 'input_2' => 'input_58', // envia el Nº de personas al ZOHO |
| 7 | + | 'input_2' => 'input_58', // envia el Nº de personas al ZOHO |
| 8 | - | 'input_55' => 'input_59', // envia los extras al ZOHO |
| 8 | + | 'input_55' => 'input_59', // envia los extras al ZOHO |
| 9 | - | 'input_27' => 'input_60', // envia forma de pago al ZOHO |
| 9 | + | 'input_27' => 'input_60', // envia forma de pago al ZOHO |
| 10 | - | 'input_52' => 'input_61'); // envia la población al ZOHO |
| 10 | + | 'input_52' => 'input_61'); // envia la población al ZOHO |
| 11 | ||
| 12 | - | // define the separator |
| 12 | + | // define the separator one time |
| 13 | - | $needle = '|'; |
| 13 | + | $needle = '|'; |
| 14 | ||
| 15 | - | // loop through all the field pairs |
| 15 | + | // loop through all the field pairs |
| 16 | - | // the unmodified value is stored in $_POST[$original] |
| 16 | + | // the unmodified value is stored in $_POST[$original] |
| 17 | - | // and after modification it will be assigned to $_POST[$hidden] |
| 17 | + | // and after modification it will be assigned to $_POST[$hidden] |
| 18 | - | foreach ($field_pair as $original => $hidden) {
|
| 18 | + | foreach ($field_pair as $original => $hidden) {
|
| 19 | - | $haystack = $_POST[$original]; |
| 19 | + | // deal with field 55 differently because it is checkboxes |
| 20 | - | $result = substr($haystack, 0, strpos($haystack, $needle)); |
| 20 | + | if($original == 'input_55') {
|
| 21 | - | $_POST[$hidden] = $result; |
| 21 | + | // start with an empty $result string |
| 22 | - | } |
| 22 | + | $result = ''; |
| 23 | // there are 23 checkboxes but _10 and _20 are skipped, so we need to count to 25 | |
| 24 | - | // return the form |
| 24 | + | for($i=1; $i <= 25; $i++) {
|
| 25 | - | return $form; |
| 25 | + | // each checkbox choice |
| 26 | $choice = $original . "_$i"; | |
| 27 | // make sure the choice was submitted before checking the value | |
| 28 | if(isset($_POST[$choice])) {
| |
| 29 | $haystack = $_POST[$choice]; | |
| 30 | $result .= substr($haystack, 0, strpos($haystack, $needle)) . '; '; | |
| 31 | } | |
| 32 | } | |
| 33 | // assign the result string to the hidden field 60 | |
| 34 | // trim off the trailing semicolon and space first | |
| 35 | $_POST[$hidden] = substr($result, 0, (strlen($result)-2)); | |
| 36 | } | |
| 37 | else {
| |
| 38 | $haystack = $_POST[$original]; | |
| 39 | $result = substr($haystack, 0, strpos($haystack, $needle)); | |
| 40 | $_POST[$hidden] = $result; | |
| 41 | } | |
| 42 | } | |
| 43 | ||
| 44 | // return the form | |
| 45 | return $form; | |
| 46 | } |