PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Populate drop down with existing users first and last name as one option

  1. I'm looking for a way populate a drop down field with existing users first and last name, so other users can make a selection based on that info.

    I am in a dance association and I am working on an online registration form. To balance classes (even number of men / women), I let members sign up one at a time - even though they want to dance together as a couple.

    The idea is that (for example) the man sign up first. Then I create a user for him. Then the woman should sign up and in one drop down (partner info) be able to see all created users (first and last name) and select her partner.

    How do I do that?

    Posted 7 years ago on Thursday August 23, 2012 | Permalink
  2. I'm looking at:

    http://www.gravityhelp.com/documentation/page/Dynamically_Populating_the_Post_Author
    http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population
    http://www.gravityhelp.com/documentation/page/Allow_field_to_be_populated_dynamically

    and I still can't figure out how to populate a drop down with first name and last name of registered users in wordpress.

    Any hints?

    Posted 7 years ago on Monday September 17, 2012 | Permalink
  3. So your drop down would look like "Chris Hajer" where the first name is Chris and last name is Hajer? You want one value for both in your drop down, and every selection will be a combination of the first and last name of each registered user?

    Posted 7 years ago on Tuesday September 18, 2012 | Permalink
  4. Precisely.

    Dana send me some code example yesterday through priority support, which I will try when I get home. Sorry for the double posting. This one started a long time ago.

    Should I post the solution here if I get it to work?

    Posted 7 years ago on Wednesday September 19, 2012 | Permalink
  5. Yes, please post the solution here. I did not know you started a priority support ticket.

    Posted 7 years ago on Thursday September 20, 2012 | Permalink
  6. Yeah, I'm sorry about that. I waited two weeks in here before going priority. Dana sent me:

    "To dynamically populate your drop down with users, you need to check the option on the Advanced tab called "Allow field to be populated dynamically" for your drop down field. You do not provide a parameter name. You will use the gform_pre_render filter in your functions.php file. I have created an example for you which uses the WordPress function "get_users()" to get users. :)

    Take a look at the example here: http://pastie.org/4751675 .

    The WordPress documentation for the get_users function can be found at http://codex.wordpress.org/Function_Reference/get_users - in case you want to add more filtering to the get_users function than what I used in the example.

    The documentation for the gform_pre_render function can be found at http://www.gravityhelp.com/documentation/page/Gform_pre_render . I used the examples here as my basis for building the function for populating a drop down with user information."

    When you set up the drop down, you will be shown display_name, which wasn't quite what I wanted.

    I found that I could change that when I connected the form to user registration and set the shown name to last name/first name in there.

    Then I have my last and first name in the drop down :)

    Posted 7 years ago on Thursday September 20, 2012 | Permalink
  7. Thank you for posting those instructions for the benefit of all.

    Posted 7 years ago on Saturday September 22, 2012 | Permalink

This topic has been resolved and has been closed to new replies.