Populate list of users in Fluent Form dropdown

tdrayson

I had a situation where I wanted to be able to display a list of all the users on the website in my form using Fluent Forms.

We can achieve this easily using the fluentform/rendering_field_data_select filter.

1. Create our form

First we need to configure our form, ready for our snippet. To do this we are going to add a dropdown field.

image 1

Next we need to open the advanced options for the field and set our name attribute. This is a unique key we can target in the code.

image

2. Add the code

We are going to be using the hook fluentform/rendering_field_data_select. You can read more about this hook here .

Defining some variables

Inside our hook, we’re going to define a couple of constants that we’ll use throughout the snippet.

  • $id – this is your form ID that you want this to apply to
  • $field_name – this is the name attribute that we set our field we just created.

Members content only

Become a snippetclub.com member to gain instant access to this tutorial plus tons more premium content.

Already a member? Log in below.

Login Form

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

Newsletter

🔒I won't send you spam, I promise