Elementor form custom webhook returns "error" message

Viewed 3013

I'm using Elementor form with custom webhook but every time I submit it, I just get "error" message.

enter image description here

In my functions.php file I've got Form New Record Action according Forms API documentation.

// A send custom WebHook
add_action( 'elementor_pro/forms/new_record', function( $record, $handler ) {

    $form_name = $record->get_form_settings( 'form_name' );

    if ( 'test_form' !== $form_name ) {
        return;
    }

    $raw_fields = $record->get( 'fields' );
    $fields = [];
    foreach ( $raw_fields as $id => $field ) {
        $fields[ $id ] = $field['value'];
    }

    wp_remote_post( 'https://example.com', [
        'body' => $fields,
    ]);
}, 10, 2 );

I have "wp_remote_post" there with URL I want to post the form to, but it does not redirect me or something, just returning "error" message.

On Elementor editor I added Webhook action after form submission

enter image description here

What could be wrong? Thanks

1 Answers

In the last example you need to fill in the wbbhook field at the appropriate URL webhookfield

Related