Skip to content

Instantly share code, notes, and snippets.

@khleomix
Created October 31, 2022 21:19
Show Gist options
  • Save khleomix/f2c8a6c2aeab3543eac63b76ebc5632d to your computer and use it in GitHub Desktop.
Save khleomix/f2c8a6c2aeab3543eac63b76ebc5632d to your computer and use it in GitHub Desktop.
ACF Gravity Forms Select
<?php
/**
* Populate ACF select field options with Gravity Forms form ID
*/
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