Skip to content

Is This Github Page Still Supported #5

Open
@nootkan

Description

@nootkan

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);`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions