Skip to content

Instantly share code, notes, and snippets.

@ahsannayem
Created July 6, 2023 09:44
Show Gist options
  • Save ahsannayem/462746840add7eff4fa367de7db1030c to your computer and use it in GitHub Desktop.
Save ahsannayem/462746840add7eff4fa367de7db1030c to your computer and use it in GitHub Desktop.
Fluent Forms Validate the Date
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);
@bewj
Copy link

bewj commented Sep 22, 2023

how to validate by quantity and check if still availble in stock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment