Description
Haven't seen any replies or updates so just wanted to see if anyone will reply to an issue with the following snippet:
php-snippets/custom-validation-example.php
Using the free version of fluentforms Version 5.1.2 with astra theme and elementor/pro plugins.
Tried to add the snippet from the above path to my child themes function php file.
When filling out the contact form and placing my own url inside the message field it still gets sent.
ID used is from the shortcode id for the form.
Appreciate some feedback or suggestions:
`// Block links in text area of fluent form
add_filter('fluentform_validate_input_item_input_email', function ($error, $field, $formData, $fields, $form) {
/*
* add your banned sub-strings and form it here
* If the textarea has any match it will make the form submission failed
*/
// You may change the following 3 lines
$targetFormId = 4;
$bannedStrings = ['http', 'https', 'www'];
$errorMessage = 'No Url is allowed in textarea';
if ($form->id != $targetFormId) {
return $error;
}
$fieldName = $field['name'];
if (empty($formData[$fieldName])) {
return $error;
}
foreach ($bannedStrings as $string) {
if(strpos($formData[$fieldName], $string) !== false) {
return [$errorMessage];
}
}
return $error;
}, 10, 5);`