Created
August 31, 2022 22:07
-
-
Save uamv/62c6cf9f494bc86f545f33d183ccdf20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remap nested forms for multisite global forms | |
add_filter( 'gform_form_post_get_meta', function( $form ) { | |
if ( ! class_exists( 'GH_MGF' ) || is_main_site() ) { | |
return $form; | |
} | |
$primary_form_id = GH_MGF::get_primary_form_id( rgar( $form, 'id' ) ); | |
foreach ( $form['fields'] as &$field ) { | |
if ( $field->get_input_type() === 'form' ) { | |
$primary_matching_field = GH_MGF::do_network_request( SITE_ID_CURRENT_SITE, [ 'GFAPI', 'get_field' ], [ $primary_form_id, $field->id ] ); | |
$matching_child_form_id = GH_MGF::get_child_form_id( $field->gpnfForm ); | |
if ( $matching_child_form_id ) { | |
$field->gpnfForm = $matching_child_form_id; | |
} | |
} | |
} | |
return $form; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment