dongpu7881
2019-04-22 22:12
浏览 148
已采纳

多站点 - 从多站点上的另一个站点将ACF值从当前站点传递到Gravity Forms表单

I'm trying to pass data from Advance Custom Fields into my Gravity Forms form. The problem I'm running into is that the form is being generated from another site on the multisite via:

<?php switch_to_blog(1);?>   
     <?php echo do_shortcode( '[gravityform id="3" title="false" 
     description="false"]' ); ?>
<?php restore_current_blog(); ?>

In my functions.php file (for both blog 1 and the current site), I have:

add_filter( 'gform_field_value_lead_source_detail', 'populate_lead_source_detail' );
function populate_lead_source_detail( $value ) {

   $leadsourcedetail = get_field('lead_source_detail', $post->ID);
   return $leadsourcedetail;
}

add_filter( 'gform_field_value_lifecycle_status', 'populate_lifecycle_status' );
function populate_lifecycle_status( $value ) {
   $lifecycle = get_field('lifecycle_status', $post->ID);
   return $lifecycle;
}

add_filter( 'gform_field_value_lead_source', 'populate_lead_source' );
function populate_lead_source( $value ) {
   $leadsource = get_field('lead_source', $post->ID);
   return $leadsource;
}

add_filter( 'gform_field_value_channel', 'populate_channel' );
function populate_channel( $value ) {
   $channel = get_field('channel', $post->ID);
   return $channel;
}

add_filter( 'gform_field_value_expected_op_type', 'populate_expected_op_type' );
function populate_expected_op_type( $value ) {
   $expected = get_field('expected_op_type', $post->ID);
   return $expected;
}

The ACF fields work perfectly on blog 1, where the Gravity Form is being generated from, but I can't get them to pass the data to the form on the current current blog.

To make sure the ACF fields work (in general), I tested <?php the_field(); ?> for each of them, and the data is definitely there... so I'm assuming it has something to do with the fact that I'm pulling the form from a different site on the multisite.

Anyone have any ideas on how to pass data from my current site to the blog 1 form? Thanks in advance!

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题