Created
August 6, 2017 22:41
-
-
Save bmdinteractive/f8a8897ad9a437f7b0dd56f554d97134 to your computer and use it in GitHub Desktop.
Load All Ninja Forms into Advance Custom Fields Dropdown
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
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