Filter lookup based on criteria

By: Marise Sal | Asked: 03/22/2025
ForumsCategory: General questionsFilter lookup based on criteria
Marise Sal asked 4 weeks ago

Is there a way to limit lookup drop-down based on some criteria.

2 Answers
Rob LeVineRob LeVine Staff answered 4 weeks ago

Using https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/ and/or https://formidableforms.com/knowledgebase/frm_setup_edit_fields_vars/ you can filter the dropdowns, though it might depend on what "some criteria" means.

Marise Sal replied 4 weeks ago

That didn't work, I have also followed this KB but didn't work https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/#kb-filter-dynamic-field-by-user-meta

Let's say I have a lookup field that from Department form, I want users that have meta data contains their department to be available in that lookup drop down.

Rob LeVineRob LeVine Staff replied 4 weeks ago

You'll have to be more concise than "didn't work". Put some debugging statements in and see what values are along the way. What you're trying to do is entirely possible.

Marise Sal replied 4 weeks ago

Sorry for the late reply, I set the below to match my form

11483= My first lookup
11480= Text field
hobby= user_dept

11483 to the id of the Dynamic field
11480 to the id of the field in the data form that you want to use for filtering
hobby to the key of the user meta you want to use for filtering

Then I got this error:
"Warning: Undefined array key "restrict" in /wp-content/plugins/formidable-pro/classes/controllers/FrmProDynamicFieldsController.php on line 136"

Line 136:
} elseif ( $values['restrict'] && ( $user_ID || self::should_restrict_options_for_logged_out_users( $field ) ) ) {

Rob LeVineRob LeVine Staff replied 4 weeks ago

If you have an undefine array key, then you need to deal with it. Either 'restrict' doesn't ever exist or you need to change the code to be isset($values['restrict'])

Marise Sal answered 4 weeks ago

To simplify my needs, can the lookup field show only user metadata?

Rob LeVineRob LeVine Staff replied 4 weeks ago

I don't follow, but I suggest fixing the coding errors and see what happens with your initial goal.

Marise Sal replied 4 weeks ago

Does this KB fit my needs? It only has a field for the lookup ID but no option to set the metadata.

https://formidableforms.com/knowledgebase/frm_pro_fields_in_lookup_selection/#kb-hide-a-specific-field-in-the-lookup-selection

Rob LeVineRob LeVine Staff replied 4 weeks ago

I have no idea what the hook even does. Why are you not just fixing the issues in your code that was throwing errors?

Marise Sal replied 3 weeks ago

I don't know how to fix it

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