Expanding "User ID" field to include all group/class members' IDs

By: Justin Laughlin | Asked: 10/17/2023
ForumsCategory: How-toExpanding "User ID" field to include all group/class members' IDs
Justin Laughlin asked 1 year ago
I have a form to be used regularly by small user groups. There is a dropdown field to select the group that is meeting. Once the group is selected, I'd like to include a hidden field that adds the User IDs of every group member to the form instead of just the user who is filling the form out on behalf of the group.  Thanks for the assistance!  
Rob LeVineRob LeVine replied 1 year ago

I can think of a couple of ways to do it, however, it depends on what you mean by "adds...to the form", i.e., what is your ultimate goal? When a user submits an entry, what is attached to it and what are you going to use it for later?

Justin Laughlin replied 1 year ago

Sorry for the delay - long week last week. I'd like for groups records to be associated with each member rather than just the creator so that when users log in, they would see their group records as their own regardless of whether they created/submitted it. In other words, when a user submits a group form, I'd like every group member's user ID to be attached so that the given form becomes a viewable record for every member of the group.

Victor Font replied 1 year ago

To have a user ID in WordPress, the user has to be registered in the system. This means each member of the group must register for themselves either using the standard WordPress registration processs or Formidable's User Registration add-on. Your post doesn't describe your process, only an end goal.

1. How are group members being registered to receive their individual WordPress user IDs?
2. How are users being assigned to groups?
3. Are these groups static, meaning they never change composition, or can group members drop out or be added?
4. How are group members notified that they've been added to a group?

These are just a few questions that your requirement raises. Can you define the use case in more detail please?

1 Answers
Rob LeVineRob LeVine answered 1 year ago
Based on the above, I can't say this is the "right" answer, however, it's one way to do it. Add a hidden field to the form and then using frm_after_create_entry you fill the hidden field with a comma-separated list of user ids. When you want to allow users to view, you use that list to see if the current user is in the group that can view it. That could be done using a custom shortcode in a view. If anyone has a better way, I'm all ears.

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