Turn phone number, email, or any other simple text input as a unique field. Use the input key instead of {input_key} for your input type. See the list of input keys in this link. Also, make sure the name attribute & form ID matches correctly.
For example for phone field use this hook : fluentform_validate_input_item_phone
add_filter('fluentform_validate_input_item_{input_key}', function ($errorMessage, $field, $formData, $fields, $form) { $fieldName = 'phone'; $target_form_id = 13; if($target_form_id != $form->id){ return $errorMessage; } if ($inputValue = \FluentForm\Framework\Helpers\ArrayHelper::get($formData, $fieldName)) { $exist = wpFluent()->table('fluentform_entry_details') ->where('form_id', $form->id) ->where('field_name', $fieldName) ->where('field_value', $inputValue) ->first(); if ($exist) { $errorMessage = "Error ! This field needs to be unique."; return [$errorMessage]; } } return $errorMessage; }, 10, 5);
Use this code in theme function.php file or any PHP code snippet plugin.
Feel free to share any insights or if you have a topic in mind you would like to see documentation and example code about it. For more discussion, join our Facebook group Fluent Forms Community.
Powered by BetterDocs
Your email address will not be published. Required fields are marked *
Comment
Name*
Email*
Website