# Send Gravity Forms Entries to a Webhook

> Posts every new Gravity Forms entry as JSON, with field labels as keys, to a webhook URL such as Zapier, Make, n8n or your CRM, without the paid webhooks add-on.

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

## Code

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

add_action( 'gform_after_submission', function ( $entry, $form ) use ( $wpide_gf_webhook_forms ) {
    $url = defined( 'WPIDE_GF_WEBHOOK_URL' ) ? (string) WPIDE_GF_WEBHOOK_URL : '';

    if ( ! in_array( wp_parse_url( $url, PHP_URL_SCHEME ), array( 'https', 'http' ), true ) || 'spam' === rgar( $entry, 'status' ) ) {
        return;
    }
    if ( $wpide_gf_webhook_forms && ! in_array( (int) $form['id'], array_map( 'intval', $wpide_gf_webhook_forms ), true ) ) {
        return;
    }

    $fields = array();
    foreach ( $form['fields'] as $field ) {
        if ( in_array( $field->type, array( 'html', 'section', 'page', 'captcha' ), true ) ) {
            continue;
        }
        $label            = $field->adminLabel ? $field->adminLabel : $field->label;
        $fields[ $label ] = $field->get_value_export( $entry );
    }

    $body = wp_json_encode( array(
        'form_id'    => (int) $form['id'],
        'form_title' => $form['title'],
        'entry_id'   => (int) rgar( $entry, 'id' ),
        'fields'     => $fields,
        'source_url' => rgar( $entry, 'source_url' ),
        'created'    => rgar( $entry, 'date_created' ),
        'site'       => home_url(),
    ) );

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

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

## Notes

Define WPIDE_GF_WEBHOOK_URL (and optionally WPIDE_GF_WEBHOOK_SECRET for an X-Signature HMAC header) in wp-config.php; spam entries are never sent.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Send Gravity Forms 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/
