Assign User ID to form before submission.

By: Meliora Technology | Asked: 08/23/2024
ForumsCategory: Code HelpAssign User ID to form before submission.
Meliora Technology asked 2 months ago
Hello,
  1. We have built a form that an admin user will administer. Before the form is submitted, we need to use a dynamic lookup field to select a user ID to assign to the form before it is submitted.

  2. Once the form is submitted, we need to be able to filter our view by user ID—current_user.

  3. We would then use a shortcode to allow our end users to see the entries created and assigned by the admin user.

  4. We have built our form to hold our eligibility data, which includes the user's user ID.

  5. We have built our form that contains the dynamic lookup that brings in the UserIDs from our eligibility data form.

  6. We have created a view that shows all of our entries created by the administrator.

  7. Our issue is that when we select the dynamic lookup field as our filter and assign it to the current_user within the view, and we insert the view shortcode into our web page, the entries for the current_user logged in do not display.

  8. We are unsure what step we missed to tie the form submissions to different user_id's.
Thank you for any help or guidance we could receive.

WDJ
1 Answers
Victor Font answered 2 months ago
It sounds like you did the right thing, but obviously something is amiss. Because current_user should always display the records for the currently logged in user. How did you create the dynamic dropdown on the form? What is your filter criteria on the view? please provide further details.
Meliora Technology replied 2 months ago

Hi Victor, we created the dynamic dropdown with a lookup field that looks at our eligibility form and pulls the user ID from the eligibility form. The filter for the view we use the lookup field equals or contains user ID.

Victor Font replied 2 months ago

Your error is probably in the way you're populating the dynamic field. Dynamic fields store entry ids of the record you're pulling data from. Using a dynamic field will not retrieve the value of the user's id, it will return the entry id of the entry where the id is captured.

There will never be a condition where a user id "contains". A user ID always matches on equals.

Did you follow these directions when populating your dynamic field: https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/#kb-display-user-id-dropdown-on-front-end-for-admin

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right