Created
August 23, 2022 09:54
-
-
Save tdrayson/05e2c951a57bb18eb63b51e9d4f89f9b to your computer and use it in GitHub Desktop.
Revisions
-
tdrayson created this gist
Aug 23, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ <?php /* Instructions Replace YOUR_ACF_FIELD with the name of your acf select dropdown key Add to functions.php or code snippets plugin Forms will load sorted by Title in ASC order (A to Z) Label = Form Title Value = Form ID */ if ( !function_exists('tct_select_fluent_form') ): add_filter('acf/load_field/name=YOUR_ACF_FIELD', 'tct_select_fluent_form'); function tct_select_fluent_form( $field ){ // reset choices $field['choices'] = array(); $formApi = fluentFormApi('forms'); $atts = [ 'status' => 'all', 'sort_column' => 'title', 'sort_by' => 'ASC', 'per_page' => 500, ]; $forms = $formApi->forms($atts, $withFields = false); foreach($forms['data'] as $form){ $field['choices'][ $form->id ] = $form->title; }; return $field; } endif; /* Sources: https://www.scratchcode.io/dynamically-populate-a-select-fields-choices-in-acf/ https://fluentforms.com/docs/fluent-form-php-api/ */