• Resolved blackat5445

    (@blackat5445)


    I’m trying to send the data of forminator to another url
    I use this code to send data (the auth key has been removed due to security)
    but the problem is that the form will not send the data and the network tab only show the thank you massage ajax

    add_action(‘forminator_custom_form_after_save_entry’, ‘send_form_data_to_aiem’, 10, 2);

    function send_form_data_to_aiem($entry_id, $form_id) {
    if ($form_id !== 1200) {
    return;
    }

    $entry = Forminator_API::get_entry($form_id, $entry_id);
    if (!$entry) {
        return;
    }
    
    $form_data = $entry->meta_data;
    $data = [
        [
            "Key" => "Post_ID",
            "Value" => $form_data['hidden-1']['value']
        ],
        [
            "Key" => "name",
            "Value" => $form_data['name-1']['value']
        ],
        [
            "Key" => "surname",
            "Value" => $form_data['name-2']['value']
        ],
        [
            "Key" => "email",
            "Value" => $form_data['email-1']['value']
        ],
        [
            "Key" => "telephone",
            "Value" => $form_data['phone-1']['value']
        ],
        [
            "Key" => "time_to_recontact",
            "Value" => $form_data['text-1']['value']
        ],
        [
            "Key" => "message",
            "Value" => $form_data['textarea-1']['value']
        ]
    ];
    
    if (!empty($form_data['payment']['value'])) {
        $data[] = [
            "Key" => "online_payment",
            "Value" => $form_data['payment']['value']
        ];
    }
    
    $body = json_encode(['data' => $data]);
    
    $args = [
        'body'        => $body,
        'headers'     => [
            'Authorization' => 'Bearer ',
            'Content-Type'  => 'application/json',
        ],
        'timeout'     => 60,
    ];
    
    $url = 'https://www.gestionaleaiem.it/corsi/NewRequest';
    
    $response = wp_remote_post($url, $args);
    
    if (is_wp_error($response)) {
        error_log('Forminator data sending error: ' . $response->get_error_message());
    }

    }

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @blackat5445

    Hope you’re doing well today! Thank you for reaching out to us.

    I noticed that you are using the action hook “forminator_custom_form_after_save_entry” which has been deprecated since Forminator v1.16. Please refer to the Forminator API guide here: https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/#removed-deprecated-actions

    In this case, if the submissions are done without AJAX, you can use the action “forminator_form_after_save_entry”

    However, if you’re handling submissions via AJAX you can use the action “forminator_form_after_handle_submit”

    Please let us know if this helps.

    Kind Regards,
    Saurabh

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @blackat5445

    I hope you’re well today!

    We didn’t hear back from you for quite some time so I’m marking this topic as resolved for now.

    If you have any additional questions, let us know and we’ll be happy to assist you further.

    Best regards,
    Adam

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘can’t send the data to another url’ is closed to new replies.