Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'gform_pre_render_4', 'freetrial_studios' );
- add_filter( 'gform_pre_validation_4', 'freetrial_studios' );
- add_filter( 'gform_pre_submission_filter_4', 'freetrial_studios' );
- add_filter( 'gform_admin_pre_render_4', 'freetrial_studios' );
- function freetrial_studios( $form ) {
- foreach ( $form['fields'] as &$field ) {
- if ( $field->type != 'select' || strpos( $field->cssClass, 'studio-list' ) === false ) {
- continue;
- }
- // Get the ID of post
- $studio_id = get_the_ID();
- $studios = get_field('field_557a974776dd2', $studio_id);
- if( $studios ) {
- $studio_title = get_the_title( $studio_id );
- $studio_meta = get_post_custom($studio_id);
- $choices = array();
- $locations = array();
- $p = get_post(); // gets the basic post details
- $f = get_fields(); // gets the ACF details
- $m = array_merge((array)$p, (array)$f); // merges all details into one array
- array_push($locations, $m);
- foreach ( $studios as $studio ) {
- echo '<pre>';
- print_r( get_field('field_557a974776dd2', $studio_id, false) );
- echo '....';
- print_r( get_the_title( $studio_id ) );
- echo '....';
- print_r( the_title( $studio_id ) );
- echo '....';
- print_r( $studio_meta );
- echo '....';
- print_r( $m );
- echo '....';
- echo '</pre>';
- // Populate the drop down field with values
- $choices[] = array( 'text' => $studio, 'value' => $studio );
- $field->choices = $choices;
- }
- $field->placeholder = 'Select a Studio';
- $field->choices = $choices;
- }
- }
- return $form;
- }
- Array
- (
- [0] => 102
- )
- ....Free trial form 2....113Free trial form 2....Array
- (
- [_edit_lock] => Array
- (
- [0] => 1437533210:2
- )
- [_edit_last] => Array
- (
- [0] => 2
- )
- [_wp_page_template] => Array
- (
- [0] => default
- )
- [studio_list] => Array
- (
- [0] => a:1:{i:0;s:3:"102";}
- )
- [_studio_list] => Array
- (
- [0] => field_557a974776dd2
- )
- [email_address] => Array
- (
- [0] => email@gmail.com
- )
- [_email_address] => Array
- (
- [0] => field_55add0bd111c1
- )
- )
- ....Array
- (
- [ID] => 113
- [post_author] => 2
- [post_date] => 2015-07-21 14:53:03
- [post_date_gmt] => 2015-07-21 04:53:03
- [post_content] => Form id 4
- [gravityform id="4" title="false" description="false" ajax="true"]
- [post_title] => Free trial form 2
- [post_excerpt] =>
- [post_status] => publish
- [comment_status] => open
- [ping_status] => closed
- [post_password] =>
- [post_name] => form-2
- [to_ping] =>
- [pinged] =>
- [post_modified] => 2015-07-22 12:38:31
- [post_modified_gmt] => 2015-07-22 02:38:31
- [post_content_filtered] =>
- [post_parent] => 21
- [guid] => http://website.com.au/?page_id=113
- [menu_order] => 0
- [post_type] => page
- [post_mime_type] =>
- [comment_count] => 0
- [filter] => raw
- [studio_list] => Array
- (
- [0] => 102
- )
- [email_address] => email@gmail.com
- )
- ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement