I have implemented a custom function to populate a user dropdown dynamically bas
-
Hi,
- I have implemented a custom function to populate a user dropdown dynamically based on user roles in WPForms (Refer Below Code).
The dropdown works fine on the frontend, but I am facing an issue in the backend when trying to edit an entry.
When I access the backend edit page via:
?page=wpforms-entries&view=edit&entry_id=447
the user dropdown does not function correctly.Why does the user dropdown work on the frontend but not in the backend entry edit view? (Refer Below Code)
/**
- USer list Dropdown
*
*/
function ea_userlist_dropdown( $field, $form_data ) { if( ‘select’ !== $field[‘type’] )
return $field;
$classes = explode( ‘ ‘, $form_data[‘fields’][ $field[‘id’] ][‘css’] );
if( (! in_array( ‘dynamic-userslist’, $classes ) ))
return $field;
$field[‘choices’] = array();
if(in_array( ‘dynamic-userslist’, $classes ))
{
$wp_users_list = get_users( array(
‘role__in’ => array( ‘author’,’manager-admissions’,’provc’,’director-crcs’),
‘fields’ => array( ‘ID’ , ‘display_name’ , ‘user_login’ )
));
}
foreach( $wp_users_list as $wp_user_list )
{
$display_name_choices = $wp_user_list->display_name . ” – ” .$wp_user_list->user_login;
$field[‘choices’][] = array( ‘label’ => $display_name_choices, ‘value’ => $wp_user_list->ID , ‘image’ => ” , ‘icon’ => ‘face-smile’ , ‘icon_style’ => ‘regular’);
}
return $field;
}
add_filter( ‘wpforms_field_data’, ‘ea_userlist_dropdown’, 20, 2 );
- Role-Based Access to Entries:
How can we configure a “Head” role to view and edit all entries while restricting others to their own submissions?
3.Frontend Entry Editing:
Is there a shortcode or built-in way to edit WPForms entries from the frontend instead of using the backend?
Any guidance on these issues would be greatly appreciated.Thanks,
- I have implemented a custom function to populate a user dropdown dynamically based on user roles in WPForms (Refer Below Code).
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.