Advertisement
Guest User

Untitled

a guest
Jul 21st, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. add_filter( 'gform_pre_render_4', 'freetrial_studios' );
  2. add_filter( 'gform_pre_validation_4', 'freetrial_studios' );
  3. add_filter( 'gform_pre_submission_filter_4', 'freetrial_studios' );
  4. add_filter( 'gform_admin_pre_render_4', 'freetrial_studios' );
  5. function freetrial_studios( $form ) {
  6.  
  7. foreach ( $form['fields'] as &$field ) {
  8.  
  9. if ( $field->type != 'select' || strpos( $field->cssClass, 'studio-list' ) === false ) {
  10. continue;
  11. }
  12.  
  13. // Get the ID of post
  14. $studio_id = get_the_ID();
  15. $studios = get_field('field_557a974776dd2', $studio_id);
  16.  
  17.  
  18. if( $studios ) {
  19.  
  20. $studio_title = get_the_title( $studio_id );
  21. $studio_meta = get_post_custom($studio_id);
  22. $choices = array();
  23.  
  24.  
  25. $locations = array();
  26. $p = get_post(); // gets the basic post details
  27. $f = get_fields(); // gets the ACF details
  28. $m = array_merge((array)$p, (array)$f); // merges all details into one array
  29. array_push($locations, $m);
  30.  
  31.  
  32. foreach ( $studios as $studio ) {
  33.  
  34. echo '<pre>';
  35. print_r( get_field('field_557a974776dd2', $studio_id, false) );
  36. echo '....';
  37. print_r( get_the_title( $studio_id ) );
  38. echo '....';
  39. print_r( the_title( $studio_id ) );
  40. echo '....';
  41. print_r( $studio_meta );
  42. echo '....';
  43. print_r( $m );
  44. echo '....';
  45.  
  46. echo '</pre>';
  47.  
  48. // Populate the drop down field with values
  49. $choices[] = array( 'text' => $studio, 'value' => $studio );
  50. $field->choices = $choices;
  51. }
  52.  
  53. $field->placeholder = 'Select a Studio';
  54. $field->choices = $choices;
  55. }
  56. }
  57. return $form;
  58. }
  59.  
  60. Array
  61. (
  62. [0] => 102
  63. )
  64. ....Free trial form 2....113Free trial form 2....Array
  65. (
  66. [_edit_lock] => Array
  67. (
  68. [0] => 1437533210:2
  69. )
  70.  
  71. [_edit_last] => Array
  72. (
  73. [0] => 2
  74. )
  75.  
  76. [_wp_page_template] => Array
  77. (
  78. [0] => default
  79. )
  80.  
  81. [studio_list] => Array
  82. (
  83. [0] => a:1:{i:0;s:3:"102";}
  84. )
  85.  
  86. [_studio_list] => Array
  87. (
  88. [0] => field_557a974776dd2
  89. )
  90.  
  91. [email_address] => Array
  92. (
  93. [0] => email@gmail.com
  94. )
  95.  
  96. [_email_address] => Array
  97. (
  98. [0] => field_55add0bd111c1
  99. )
  100.  
  101. )
  102. ....Array
  103. (
  104. [ID] => 113
  105. [post_author] => 2
  106. [post_date] => 2015-07-21 14:53:03
  107. [post_date_gmt] => 2015-07-21 04:53:03
  108. [post_content] => Form id 4
  109.  
  110. [gravityform id="4" title="false" description="false" ajax="true"]
  111. [post_title] => Free trial form 2
  112. [post_excerpt] =>
  113. [post_status] => publish
  114. [comment_status] => open
  115. [ping_status] => closed
  116. [post_password] =>
  117. [post_name] => form-2
  118. [to_ping] =>
  119. [pinged] =>
  120. [post_modified] => 2015-07-22 12:38:31
  121. [post_modified_gmt] => 2015-07-22 02:38:31
  122. [post_content_filtered] =>
  123. [post_parent] => 21
  124. [guid] => http://website.com.au/?page_id=113
  125. [menu_order] => 0
  126. [post_type] => page
  127. [post_mime_type] =>
  128. [comment_count] => 0
  129. [filter] => raw
  130. [studio_list] => Array
  131. (
  132. [0] => 102
  133. )
  134.  
  135. [email_address] => email@gmail.com
  136. )
  137. ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement