Plugin Directory

Changeset 3323377


Ignore:
Timestamp:
07/07/2025 09:39:33 AM (8 months ago)
Author:
jumptech
Message:

fix payload in Elementor forms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • avacy/trunk/src/Integrations/ElementorForms.php

    r3305818 r3323377  
    2020    public static function convertToFormSubmission($contact_form) : FormSubmission {
    2121        $form_id = sanitize_text_field($contact_form['id']);
    22         $identifier = get_option('avacy_elementor_forms_' . $form_id . '_form_user_identifier'); // TODO: get identifier from settings
     22        $identifierKey = get_option('avacy_elementor_forms_' . $form_id . '_form_user_identifier');
     23        $identifier = $contact_form[$identifierKey];
    2324        $remoteAddr = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
    2425        $ipAddress = $remoteAddr ?: '0.0.0.0';
     
    2728        $fields = self::getFields($form_id);
    2829        $selectedFields = [];
    29 
    3030        foreach($fields as $field) {
    31             if(isset($submittedData[$field])) {
    32                 $selectedFields[$field] = sanitize_text_field($submittedData[$field]);
     31            if(!empty($field)) {
     32                $selectedFields[] = [
     33                    'label' => $field,
     34                    'value' => $contact_form[$field]
     35                ];
    3336            }
    3437        }
    3538
    36         $proofs = sanitize_text_field($contact_form['source']);
     39        $proof = sanitize_text_field($contact_form['source']);
     40        $consentData = wp_json_encode($selectedFields);
    3741
    38         // TODO: get legal notices from settings
    39         $legalNotices = [
    40             ["name" => "privacy_policy"],
    41             ["name" => "cookie_policy"]
     42        $consentFeatures = [
     43            'privacy_policy',
     44            'cookie_policy'
    4245        ];
    4346
    44         // TODO: get preferences from settings
    45         $preferences = [
    46             [
    47                 "name" => "newsletter",
    48                 "accepted" => true
    49             ],
    50             [
    51                 "name" => "updates",
    52                 "accepted" => true
    53             ]
    54         ];
     47        $sub = new FormSubmission(
     48            $ipAddress,
     49            'form',
     50            'accepted',
     51            $consentData,
     52            $identifier,
     53            'plugin',
     54            $consentFeatures,
     55            $proof
     56        );
    5557
    56         return new FormSubmission(
    57             $selectedFields,
    58             $identifier,
    59             $ipAddress,
    60             $proofs,
    61             $legalNotices,
    62             $preferences
    63         );
     58        return $sub;
    6459    }
    6560
Note: See TracChangeset for help on using the changeset viewer.