Advertisement
RUSSEL86

Gravity form Collection

Jun 29th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. /* -------------------------------------------------------------------------------------
  2. UUID (universal unique id) for forms
  3. ----------------------------------------------------------------------------------- */
  4. add_filter("gform_field_value_uuid", "get_unique");
  5. function get_unique(){
  6. $num = 0;
  7. $prefix = intval( date("Ymd") ); // update the prefix here
  8. $uniques = sprintf("%04d", $num);
  9. $unique = $prefix . $uniques;
  10. do {
  11. $unique += 1;
  12. } while (!check_unique($unique));
  13. return $unique;
  14. }
  15. function check_unique($unique) {
  16. global $wpdb;
  17.  
  18.  
  19. $table = $wpdb->prefix . 'rg_lead_detail';
  20. $form_id2 = 2; // update to the form ID your unique id field belongs to
  21. $field_id2 = 93; // update to the field ID your unique id is being prepopulated in
  22. $result2 = $wpdb->get_var("SELECT value FROM $table WHERE form_id = '$form_id2' AND field_number = '$field_id2' AND value = '$unique'");
  23.  
  24. if(empty($result2)){
  25. return true;
  26. } else {
  27. return false;
  28. }
  29.  
  30. }
  31.  
  32. /* ------------------------------
  33. gravity class for 4 columns
  34. -------------------------------*/
  35. gf_first_quarter
  36. gf_second_quarter
  37. gf_third_quarter
  38. gf_fourth_quarter
  39.  
  40. /* ------------------------------
  41. gravity class for inline
  42. -------------------------------*/
  43. gf_inline
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement