Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save techjewel/e6bf22ce3edb99719a7606a8435715fe to your computer and use it in GitHub Desktop.

Select an option

Save techjewel/e6bf22ce3edb99719a7606a8435715fe to your computer and use it in GitHub Desktop.
A Simple Code Snippet to check if the provided email in FluentForms submission is a CRM contact and is in a block lists tags.
<?php
/**
* A Simple Code Snippet to check if the provided email in FluentForms submission is a CRM contact and is in a block lists tags.
* If yes, then it will reject the form submission
*/
add_filter('fluentform/validate_input_item_email', function ($error, $field, $formData) {
if ($error || !defined('FLUENT_CRM')) {
return $error; // already an error or FLUENTCRM is not activated
}
$inputName = \FluentForm\Framework\Helpers\ArrayHelper::get($field, 'raw.attributes.name');
$inputEmail = \FluentForm\Framework\Helpers\ArrayHelper::get($formData, $inputName);
$crmContact = FluentCrmApi('contacts')->getContact($inputEmail);
$blockListTagIds = [1, 2]; // change the tags IDs
if ($crmContact && $crmContact->hasAnyTagId($blockListTagIds)) {
$error = [
'email_blocked' => __('The email address you have entered is blocked from submitting this form.', 'fluentform')
];
}
return $error;
}, 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment