Set default selected item (drop down) based on signed in user

I would like to have a drop-down list set its default value based on the logged-in user’s email address.

We have multiple domains so for example
if DropDown list default = A,
if DropDown list default = B

Does anyone know if this is possible? If it is and code is needed what file do I add it to?

You can take the approach of dynamically populating the field via hook. The filter you will use for this is gform_field_value_$parameter_name. Those documents should outline pretty well how to use this hook. In short, what you need to do…

  1. Allow field to be populated dynamically on the Advanced tab of the hidden field.
  2. Define a custom Parameter Name which can be used to the populate that field. (eg. domain_identification )
  3. Set the filter to target that specific parameter. (eg. gform_field_value_domain_identification )
  4. From the function hooked to that filter, you’d check the user’s email address and return the value to populate the field.

Reference: Where Do I Put This Code? for various ways to include the code in your site.

1 Like
© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.