Advertisement
chrishajer

Strip pricing on five fields in one function

Jan 9th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. // http://www.gravityhelp.com/forums/topic/change-option-value?replies=19#post-103945
  2. // this code will apply to form 1 only
  3. add_action('gform_pre_submission_filter_1', 'strip_pricing');
  4. function strip_pricing($form) {
  5.         $field_pair = array('input_1' => 'input_57',    // envia el Desayuno elegido al ZOHO
  6.                             'input_2' => 'input_58',    // envia el Nº de personas  al ZOHO
  7.                             'input55' => 'input_59',    // envia los extras al ZOHO
  8.                             'input_27' => 'input_60',   // envia forma de pago al ZOHO
  9.                             'input_52' => 'input_61');  // envia la población al ZOHO
  10.                            
  11.         // define the separator one time
  12.         $needle   = '|';
  13.        
  14.         // loop through all the field pairs
  15.         // the unmodified value is stored in $_POST[$original]
  16.         // and after modification it will be assigned to $_POST[$hidden]
  17.         foreach ($array as $original => $hidden) {
  18.             $haystack = $_POST[$original];
  19.             $result = substr($haystack, 0, strpos($haystack, $needle));
  20.             $_POST[$hidden] = $result;
  21.         }
  22.  
  23.         // return the form
  24.         return $form;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement