Need to create a form that does the following:
Can anyone help? or point us in the right direction?
Thanks
Mike
Picking a list via user role is custom work, but is possible using custom SQL and Formidable hooks to populate your search record. Everything else is done with the User Registration Add-on.
Appreciate the answer Victor - Thanks very much
Could you please comment on this code?
add_filter('frm_setup_new_fields_vars', 'populate_dropdown_with_users_on_form_load', 10, 2);
function populate_dropdown_with_users_on_form_load($values, $field) {
// Check if the field is the dropdown field you want to populate
if ($field->type == 'select' && $field->id == 'dropdown_field_id') {
// Get all user IDs and names
$users = get_users();
// Prepare choices array
$choices = array();
foreach ($users as $user) {
$choices[$user->ID] = $user->display_name;
}
// Modify the field configuration with the updated choices
$values['field_options']['choices'] = $choices;
}
Is this getting anything like it needs to be?
Thanks for any tips or references
Kind regards
Mike
I suggest you use the Kint debugger to see the actual values in the $values array and $field object. $field->id == 'dropdown_field_id' will never be true. 'dropdown_field_id', if anything, is a field key. Field ids are always numeric values. You asked about selecting users by user role. This snippet doesn't address the role.
Please login or Register to submit your answer