The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Display and change UserID in a dropdown on the front-end for other than admin
The way is to add the filter that was listed in frm_setup_new_fields_vars, to display the UserID in the dropdown for admins. One can add another filter with the following alteration to the code, in this case for the Editor role:
add_filter('frm_setup_new_fields_vars', 'show_user_dropdown_editor', 15, 2); add_filter('frm_setup_edit_fields_vars', 'show_user_dropdown_editor', 15, 3); function show_user_dropdown_editor($values, $field, $entry_id=false){ if ( $values['type'] == 'user_id' && !is_admin() && current_user_can('editor') ){ $values['type'] = 'select'; $values['options'] = FrmProFieldsHelper::get_user_options(); $values['use_key'] = true; $values['custom_html'] = FrmFieldsHelper::get_default_html('select'); } return $values; }
And of course, the original code is for the admin:
add_filter('frm_setup_new_fields_vars', 'show_user_dropdown', 15, 2); add_filter('frm_setup_edit_fields_vars', 'show_user_dropdown', 15, 3); function show_user_dropdown($values, $field, $entry_id=false){ if ( $values['type'] == 'user_id' && !is_admin() && current_user_can('administrator') ){ $values['type'] = 'select'; $values['options'] = FrmProFieldsHelper::get_user_options(); $values['use_key'] = true; $values['custom_html'] = FrmFieldsHelper::get_default_html('select'); } return $values; }
With both codes the Administrator and Editor roles will see the dropdown to change the UserID for any entry, on the front-end. This must work for other roles as well.
December 4, 2018 at 1:44 pm
I can't get this to work on my form. I am logged in as an admin and have a userID field, but they do not display as drop downs on the front end, they are still invisible. I added the required hook via the snippets plugin. any idea what I am doing wrong?
Discussion closed.