Created
December 12, 2022 19:43
-
-
Save evanfraser/3a4676eb767cc9493bfe375180aa63b6 to your computer and use it in GitHub Desktop.
Populate ACF select field options with Gravity Forms forms
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
<?php | |
add_filter('acf/load_field/name=gravity_form_id', function($field) { | |
if (class_exists('GFFormsModel')) { | |
$choices = []; | |
foreach (\GFFormsModel::get_forms() as $form) { | |
$choices[$form->id] = $form->title; | |
} | |
$field['choices'] = $choices; | |
} | |
return $field; | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment