# Send WPForms Entries to a Webhook

> Posts every WPForms submission as JSON with field labels as keys to a webhook URL, such as Zapier, Make, n8n or a CRM, without a paid add-on.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: wpforms, webhook, integration
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/wpforms-webhook/

## Code

```php
$wpide_wpf_webhook_forms = array(); // Form IDs to send; empty = all.

add_action( 'wpforms_process_complete', function ( $fields, $entry, $form_data, $entry_id ) use ( $wpide_wpf_webhook_forms ) {
    $url = defined( 'WPIDE_WPFORMS_WEBHOOK_URL' ) ? (string) WPIDE_WPFORMS_WEBHOOK_URL : '';

    if ( ! in_array( wp_parse_url( $url, PHP_URL_SCHEME ), array( 'https', 'http' ), true ) ) {
        return;
    }
    if ( $wpide_wpf_webhook_forms && ! in_array( (int) $form_data['id'], array_map( 'intval', $wpide_wpf_webhook_forms ), true ) ) {
        return;
    }

    $data = array();
    foreach ( (array) $fields as $field ) {
        $label          = ! empty( $field['name'] ) ? $field['name'] : 'field_' . $field['id'];
        $data[ $label ] = isset( $field['value'] ) ? $field['value'] : '';
    }

    $body = wp_json_encode( array(
        'form_id'    => (int) $form_data['id'],
        'form_title' => isset( $form_data['settings']['form_title'] ) ? $form_data['settings']['form_title'] : '',
        'entry_id'   => (int) $entry_id,
        'fields'     => $data,
        'submitted'  => gmdate( 'c' ),
        'site'       => home_url(),
    ) );

    $headers = array( 'Content-Type' => 'application/json' );
    if ( defined( 'WPIDE_WPFORMS_WEBHOOK_SECRET' ) && WPIDE_WPFORMS_WEBHOOK_SECRET ) {
        $headers['X-Signature'] = hash_hmac( 'sha256', $body, WPIDE_WPFORMS_WEBHOOK_SECRET );
    }

    wp_remote_post( $url, array( 'body' => $body, 'headers' => $headers, 'timeout' => 5, 'blocking' => false ) );
}, 10, 4 );
```

## Notes

Define WPIDE_WPFORMS_WEBHOOK_URL (and optionally WPIDE_WPFORMS_WEBHOOK_SECRET for an X-Signature HMAC header) in wp-config.php.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Send WPForms Entries to a Webhook" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
