Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is This Github Page Still Supported #5

Open
nootkan opened this issue Nov 9, 2023 · 0 comments
Open

Is This Github Page Still Supported #5

nootkan opened this issue Nov 9, 2023 · 0 comments

Comments

@nootkan
Copy link

nootkan commented Nov 9, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant