-
-
Save goranseric/0e2e4320233df58437128d20b2d41014 to your computer and use it in GitHub Desktop.
Populate ACF select field options with Gravity Forms to select a specific form
This file contains hidden or 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
| <?php | |
| /** | |
| * Populate ACF select field options with Gravity Forms forms | |
| */ | |
| function acf_populate_gf_forms_ids( $field ) { | |
| if ( class_exists( 'GFFormsModel' ) ) { | |
| $choices = []; | |
| foreach ( \GFFormsModel::get_forms() as $form ) { | |
| $choices[ $form->id ] = $form->title; | |
| } | |
| $field['choices'] = $choices; | |
| } | |
| return $field; | |
| } | |
| add_filter( 'acf/load_field/name=submit_project_gf_form_id', 'acf_populate_gf_forms_ids' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment