EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Lead capture filter data
Yurii53eb7c101b59
diff --git a/application/Espo/Tools/LeadCapture/CaptureService.php b/application/Espo/Tools/LeadCapture/CaptureService.phpindex d2de2c1f25..9239e427cb 100644--- a/application/Espo/Tools/LeadCapture/CaptureService.php+++ b/application/Espo/Tools/LeadCapture/CaptureService.php@@ -127,6 +127,8 @@ class CaptureService{$leadCapture = $this->getLeadCapture($apiKey);+ $this->filterData($leadCapture, $data);+if (!$leadCapture->optInConfirmation()) {$this->proceed($leadCapture, $data);@@ -798,4 +800,23 @@ class CaptureService$lead->set(Field::PIPELINE_STAGE . 'Id', $firstStage->getId());$lead->set(Field::PIPELINE_STAGE . 'Name', $firstStage->getName());}++ private function filterData(LeadCapture $leadCapture, stdClass $data): void+ {+ $fieldList = $leadCapture->getFieldList();++ $attributeList = [];++ foreach ($fieldList as $field) {+ $fieldAttributeList = $this->fieldUtil->getActualAttributeList(Lead::ENTITY_TYPE, $field);++ $attributeList = array_merge($attributeList, $fieldAttributeList);+ }++ foreach (array_keys(get_object_vars($data)) as $k) {+ if (!in_array($k, $attributeList)) {+ unset($data->$k);+ }+ }+ }}