Created
July 6, 2023 09:44
-
-
Save ahsannayem/462746840add7eff4fa367de7db1030c to your computer and use it in GitHub Desktop.
Fluent Forms Validate the Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('fluentform_validate_input_item_input_date', function ($errorMessage, $field, $formData, $fields, $form) { | |
$fieldName = 'weddingdate'; | |
$target_form_id = 104; | |
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 = "Thank you for your interest, however another couple has booked me for this day. Please reach out via the Contact form and I'd be happy to recommend other great photographers who can capture your day."; | |
return [$errorMessage]; | |
} | |
} | |
return $errorMessage; | |
}, 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to validate by quantity and check if still availble in stock