No need to explain, let’s dive into code!
add_filter( 'acf/load_field/name=donation_form', array( $this, 'populate_forms' ) );
public function populate_forms( $field ) {
$choices = array(
'select' => '-- Select a form',
);
$forms = \GFAPI::get_forms();
foreach ( $forms as $choice ) {
$choices[ $choice['id'] ] = $choice['title'];
}
$field['choices'] = $choices;
return $field;
}
Leave a Reply