Skip to content

Instantly share code, notes, and snippets.

@bmdinteractive
Created August 6, 2017 22:41
Show Gist options
  • Save bmdinteractive/f8a8897ad9a437f7b0dd56f554d97134 to your computer and use it in GitHub Desktop.
Save bmdinteractive/f8a8897ad9a437f7b0dd56f554d97134 to your computer and use it in GitHub Desktop.
Load All Ninja Forms into Advance Custom Fields Dropdown
function acf_load_ninja_form_field_choices( $field ) {
// reset choices
$field['choices'] = array();
$ninja_forms = Ninja_Forms()->form()->get_forms();
foreach($ninja_forms as $nf):
$value = '[ninja_forms id='.$nf->get_id().']';
$nf_settings = $nf->get_settings();
$label = $nf_settings['title'];
$field['choices'][$value] = $label;
endforeach;
// return the field
return $field;
}
add_filter('acf/load_field/name=ninja_form', 'acf_load_ninja_form_field_choices');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment