How to add WordPress user select dropdown in formidable form.

Hello,

 

In my project, I want to add specific user data from front-end.

In that form I need to give wordpress all users (subscribers)  dropdown to select and add that form data for selected users.

In short how to add subscriber users in  formidable form dtopdown dynamically.

Can we use frm_setup_new_fields_vars filters to do this ? How ?

 

Thanks in advance.

What is the end goal with selecting users? What are you doing with it? Before getting into custom code, I'm trying to determine whether you need to use a user ID field or not.

In my platform one user(DOCTOR) can make another user(PATIENTS) medical entry.

In my WP patients are one kind of user. So in my formidable form I want dropdown to select patients (users).

 

Ex: 

<select>
<option value="12">Bob</option>
<option value="8">John</option>
<option value="25">Can</option>
<option value="13">Peater</option>
</select>

Where vale is user id.

 

I understand you want a list of the users, but you didn't really answer my questions. What is the end goal with selecting users? Will you be displaying this info somewhere using a custom display? What will you be displaying? Who can see and/or edit it?

In my platform there is 2 users role, Doctor & Patients.

What is the end goal with selecting users? 

After login Doctor user can make patients entry, so Doctor user select patients(user) name from that dropdown list in formidable form to make his entry.

Will you be displaying this info somewhere using a custom display? 

I will display that entry using custom display.

What will you be displaying? 

After Patients Login, they can see only their entry which is made by doctor.

Who can see and/or edit it?

Only Doctor can edit it, Patient can see or delete it.

 

Let me just know how to display dropdown list with WP users, I will manage other tings my self.

 

Thanks.

 

Only Doctor can edit it, Patient can see or delete it.

This part adds a lot of complication. So you'd leave the user ID field alone so the doctor can edit, but we link editing and deleting, so if a user has permission to edit, then they have permission to delete. If no editing, then no deleting either. This is built to work this way for the user who submits the entry, but not for a second user, so it would require quite a bit of custom code. You may need to hire a developer.

So, yes, you would use the frm_setup_new_fields_vars to populate the patent drop-down.
http://formidablepro.com/knowledgebase/formidable-hooks/frm_setup_new_fields_vars/
Here's a related post:
http://formidablepro.com/help-desk/setting-a-post-author/

You'd need to create two different custom displays: one for doctors, and one for patients. In the patient custom display, you would filter the entries in the "advanced" box with:
Patient field is equal to [user-meta key=ID]

Thanks Stephanie Wells,

This filter works for me for specific form id to generate user list drop-down.

Is there any way to make it dynamic.

Suppose can I create drag&drop user dropdown fields for formidable backend.

So user can us that field for any fields id of form.

 

Creating a new field type would take a lot of work. You are welcome to download and copy the signature add-on, but this falls outside the scope of our support. The fast way would be to use the field keys. For example, you could use field keys like patients_23 and patients_24. 23 and 24 are just random. It doesn't matter what you use. Then, you'd change the line in code from:
if($field->id == 137){
to:
if(preg_match('/patients*/', $field->field_key))

Topic closed.