Skip to content

Instantly share code, notes, and snippets.

@nkb-bd
Created September 4, 2020 10:35
Show Gist options
  • Select an option

  • Save nkb-bd/6ce3b9372c57043f5aed2f2fa719d46f to your computer and use it in GitHub Desktop.

Select an option

Save nkb-bd/6ce3b9372c57043f5aed2f2fa719d46f to your computer and use it in GitHub Desktop.
fluent form users list in dropdown input
/*
* 1. Add this in function.php file
* 2. Change form ID
* 3. Change input attribute name
*/
add_filter('fluenform_rendering_field_data_select', function ($data, $form) {
if ($form->id != 91) {
return $data;
}
//default name of the dropdown input is 'dropdown'
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'dropdown') {
return $data;
}
$blogusers = get_users();
// Array of WP_User objects.
foreach ( $blogusers as $user ) {
$array[] = array("label"=>$user->display_name, "value"=>$user->display_name, "calc_value"=>"");
}
// We are merging with existing options here
$data['settings']['advanced_options'] = array_merge($data['settings']['advanced_options'], $array);
return $data;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment