Last active
November 10, 2022 03:51
-
-
Save yankiara/cc4745383ec54539ca73a6e9e997625d to your computer and use it in GitHub Desktop.
Dynamically populate Fluentform dropdown select menu
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 characters
<?php | |
add_filter('fluentform_rendering_field_data_select', function ($data, $form) { | |
if ($form->id != 10) | |
return $data; | |
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'poste') | |
return $data; | |
$jobs = get_posts( [ 'post_type' => 'job' ] ); | |
foreach( $jobs as $job ) { | |
$data['settings']['advanced_options'][] = | |
[ | |
"label" => $job->post_title, | |
"value" => $job->post_title, | |
"calc_value" => "" | |
]; | |
}; | |
return $data; | |
}, 10, 2); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The name 'fluenform_rendering_field_data_select' has changed in newer versions of Fluent Forms to 'fluentform_rendering_field_data_select' (with a t after fluen).