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

Slack Signup
Newsletter Optin
Help Desk

Filter by Current User ID

Labels

This Discussion is public

Notifications

We are trying to build an anonymous employee feedback assessment. Managers are created as subscribers in WP and then imported dynamically into a field for the employee form as a dropdown. The code we used for this is:

add_filter('frm_setup_new_fields_vars', 'frm_populate_user_dropdown', 10, 2);add_filter('frm_setup_new_fields_vars', 'frm_populate_user_dropdown', 10, 2);add_filter('frm_setup_edit_fields_vars', 'frm_populate_user_dropdown', 10, 2);function frm_populate_user_dropdown( $values, $field ){ if ( $field->id == 224 ) { $role = 'Subscriber'; $users = get_users( array( 'role' => $role ) ); $values['options'] = array( '' => '' ); foreach ( $users as $user ) { $values['options'][] = array( 'label' => $user->display_name, 'value' => $user->ID ); } } return $values;}

Now when the employee enters their assessment, they can select their manager from the dropdown. There are a couple of other options to select and then when submitted, all of the data gets collected. The issue is the filtering. Right now all results are being pulled in and we only want the entries associated with the currently logged in manager.

 

Here is our layout of forms and views:

Currently have two forms.

  • Form A - Manager Assessment Form
  • Form B - Employee Feedback Form

Currently have 1 view:

  • View A - currently pulls in all form results from Form B

 

I also included some screenshots that shows our setup. One screenshot shows the manager dropdown in Form B, one shows the view that is created from the employee form and the final is what are currently seeing in the view results.

Any help would be greatly appreciated.

 


Attachments:

You need to be filtering on manager id equals current_user. See the 3rd section down on this page: https://formidableforms.com/knowledgebase/filtering-entries/

Discussion closed.