Advertisement
chrishajer

Revised code for stripping text after pipe

Jan 9th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // v 0.3 Revised January 9, 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');
  5. function strip_pricing_again($form) {
  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
  8.                             'input_55' => 'input_59',   // envia los extras al ZOHO
  9.                             'input_27' => 'input_60',   // envia forma de pago al ZOHO
  10.                             'input_52' => 'input_61');  // envia la población al ZOHO
  11.  
  12.         // define the separator
  13.         $needle   = '|';
  14.  
  15.         // loop through all the field pairs
  16.         // the unmodified value is stored in $_POST[$original]
  17.         // and after modification it will be assigned to $_POST[$hidden]
  18.         foreach ($field_pair as $original => $hidden) {
  19.             $haystack = $_POST[$original];
  20.             $result = substr($haystack, 0, strpos($haystack, $needle));
  21.             $_POST[$hidden] = $result;
  22.         }
  23.  
  24.         // return the form
  25.         return $form;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement