Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. function pre_submission_handler_services_7($form){
  2.  
  3. $form_id = 7;
  4. $form_raw = GFAPI::get_form($form_id);
  5.  
  6. // Grab memberium tags from database
  7.  
  8. global $wpdb;
  9. $memberiumtagsarray = $wpdb->get_results("SELECT * FROM memberium_tags WHERE category = '13' ORDER BY name ASC");
  10.  
  11. // Grab checkbox fields from GFAPI
  12.  
  13. $inputarray = $form_raw[fields][2][inputs];
  14.  
  15. // Define array to be used for tags when theres a match
  16.  
  17. $services = array();
  18.  
  19. // Iterate through array looking for matches for checked boxes
  20.  
  21. foreach ($inputarray as $key => $val) {
  22.  
  23. $inputarray[$key][id] = "input_".str_replace(".", "_", $inputarray[$key][id]);
  24.  
  25. if($_POST[$inputarray[$key][id]] !== NULL) {
  26. array_push($services, $memberiumtagsarray[$key]->id);
  27. }
  28. }
  29.  
  30. // post the array as comma delimited into field 26
  31.  
  32. $_POST["input_26"] = implode(", ",$services);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement