Hi,
I found this code below on https://formidableforms.com/knowledgebase/frm_validate_field_entry/#kb-check-for-an-allowed-value-coupons
Looks like exactly what I need, but I need the posted value in the array to by dynamic rather than hard coded.
How can check another form (for example form B) if an entry key exists, then the coupon entered on form A is valid.
add_filter('frm_validate_field_entry', 'my_custom_validation', 10, 3); function my_custom_validation($errors, $posted_field, $posted_value){ if($posted_field->id == 25){ //change 25 to the ID of the field to validate if(!in_array($posted_value, array('001','002'))){ //change 001 and 002 to your allowed values //if it doesn't match up, add an error: $errors['field'. $posted_field->id] = 'That field is wrong!'; } } return $errors; }
OpenAI suggested to use global $wpdb object. Then do something like this:
// replace 'wp_frm_item_metas' with your table name and 'value' with your column name $allowed_values = $wpdb->get_col('SELECT value FROM wp_frm_item_metas WHERE field_id = 11');
But maybe there's a better way within formidable forms alone. Like the API actions, etc.
Please login or Register to submit your answer