Gravity Forms SIREN/SIRET Field

Gravity Forms SIRET Field — Validate French Companies against the INSEE Sirene Register

Verify French companies right inside your Gravity Forms — SIRET and SIREN numbers checked
against the official INSEE Sirene register, with the company name, legal form, activity code and full
address coming back with them. Real server-side validation, a built-in 35-day cache, and a reusable
lookup library for developers. No Composer, no external libraries, no monthly fees.

Whether you run B2B onboarding, e-invoicing intake, reseller registration or any form that captures a
French company number, this add-on makes sure the value you store is a real, existing company —
not just fourteen digits that look plausible. And instead of only saying “valid”, it hands you the
company’s register data.

Why you’ll love it

  • Real validation, not just a regex. Length and the Luhn check
    digit are verified on the server — including the documented La Poste exception — before
    any network call is made.
  • Official register lookup. Confirms the number against the
    INSEE Sirene API v3.11, the authoritative French business register.
  • You get the company, not just a yes. Legal name, trade name, legal form,
    APE/NAF activity code, enterprise category, founding date, head-office flag, administrative
    status and the complete address.
  • Built-in 35-day cache. Repeat submissions of the same number never cost an API
    call — and a stale cache entry even serves as a fallback when INSEE is unreachable.
  • Never loses a submission to an outage. Only a definitive not in the
    register
    blocks. Missing key, rate limit, timeout or server error can never reject a
    legitimate customer.
  • ⌨️ Input that feels right. The number is typed in blocks exactly as it is
    printed — 123 456 789 00012 — with auto-advance and automatic paste-splitting.
  • Developer-friendly. Ships a standalone, Gravity-Forms-independent lookup
    library plus reusable siren and siret Settings API field types.
  • Translation-ready. English, German and French included, fully
    internationalized — so the form can speak the language of the companies it validates.

Key features

A dedicated SIRET / SIREN form field

  • Drag-and-drop field in the form editor, grouped under e-Invoicing Fields.
  • A per-field selector for the identifier type: SIRET (14 digits, establishment) or
    SIREN (9 digits, legal unit) — the input layout follows automatically.
  • Grouped block input: 123 456 789 00012 (3·3·3·5) for a SIRET, 123 456 789
    (3·3·3) for a SIREN. Focus advances when a block is full, Backspace walks back, and pasting a
    complete number spreads it across the blocks.
  • Stored digits-only, displayed grouped again in the entry detail view and in exports.

Robust, layered validation (server-side)

  1. Local checksum — correct length for the configured type plus the
    Luhn check digit, including the La Poste exception. A typo is caught
    instantly, without a single network request.
  2. Online lookup — the number is confirmed against the
    INSEE Sirene API using your API key from the current
    portail-api.insee.fr portal.

Robustness first: only a definitive not in the register (HTTP 404) ever blocks a
submission. A missing or rejected key, a rate limit, a timeout or a server error is reported as
unavailable — and the locally checksum-validated value is accepted.

The company data comes with it

A confirmed lookup returns a complete, normalized record:

  • Legal name (or the person’s name for a sole trader) and the trade name (enseigne).
  • Legal category, APE / NAF activity code and enterprise category
    (PME / ETI / GE).
  • Founding date, head-office flag and the administrative status of both the legal unit and the
    establishment.
  • The full establishment address — street number, street type, street name, postal code, city and
    the INSEE commune code.
  • The complete raw JSON response, kept for debugging and later re-parsing.

Optional “must be active” rule

Decide whether a company that exists but is administratively ceased (legal unit) or
closed (establishment) counts as invalid, or whether any register hit is good enough. One
checkbox in the settings.

A cache that pays for itself

  • Every confirmed record is stored for 35 days, so the same number is never looked
    up twice — helpful with INSEE’s 30-requests-per-minute limit.
  • The table is created and kept up to date automatically; a plain SQL file is included for manual
    setup or inspection.
  • Selectable cache table: use the plugin’s own table, share an existing
    schema-compatible table with other add-ons, or switch the database cache off entirely.

Optional Gravity Forms mirror

Write the register data into a Gravity Forms form via the GFAPI — one entry per
company, updated in place when the record is refreshed. You get a browsable, searchable, exportable copy
of everything the add-on has ever looked up. A ready-to-import form is included, built
with the plugin’s own SIRET field for the identifiers, a date field for the founding date
and an address field for the address.

Reusable lookup library (for developers)

The whole engine — Luhn checks, the INSEE call, the cache, the GFAPI mirror — lives in a standalone
class with no hard dependency on Gravity Forms, so any of your plugins can use it:

$insee = ( new SP_INSEE_Validator() )
    ->set_api_key( 'YOUR-KEY' )
    ->set_require_active( false )
    ->set_db_table( $wpdb->prefix . 'sp_insee_cache' );

$result = $insee->check_siret( '67205008502051' );
// $result['status']  => 'valid' | 'invalid' | 'unavailable'
// $result['record']  => name, address, APE code, founding date, ...

Reusable Settings API fields (siren / siret)

Use the same validation inside any add-on’s plugin or feed settings:

$fields[] = array(
    'name'  => 'company_siret',
    'type'  => 'siret',                          // or 'siren'
    'label' => __( 'Company SIRET', 'your-textdomain' ),
    'class' => 'medium',
);

Good to know: SIREN, SIRET and NIC

  • SIREN (9 digits) identifies the legal unit — the company itself.
  • NIC (5 digits) is the establishment suffix within that company.
  • SIRET (14 digits) identifies one establishment and is always
    SIREN + NIC.

Both carry a Luhn check digit — which is exactly why this add-on can reject a typo before it ever
touches the network.

What’s included

  • The plugin: SIRET / SIREN form field, reusable siren / siret Settings API fields
    and the shared settings page.
  • The standalone SP_INSEE_Validator lookup library (Luhn + INSEE + cache + GFAPI).
  • A ready-to-import Gravity Forms response form for the register data.
  • A plain SQL file for the cache table.
  • English, German and French translations (.po / .mo /
    .pot).
  • Full documentation in English and German (README + feature overview).
  • Clean, heavily commented, object-oriented code — easy to read, extend and audit.

Requirements & compatibility

  • WordPress with Gravity Forms ≥ 2.5
  • PHP ≥ 7.4 (with the standard json extension)
  • An INSEE Sirene API key — free, from portail-api.insee.fr. Without a key
    the local checksum validation still works and never blocks a submission.
  • Works alongside the companion Gravity Forms VAT ID Field and
    SEPA Fields add-ons — they share the same “e-Invoicing Fields” group and settings
    page without conflicts.
  • Full Gravity Forms logging support (Forms → Settings → Logging), so any
    failed lookup is easy to trace.

Privacy / GDPR

When the online lookup is enabled, the submitted SIREN / SIRET is transmitted to the French
National Institute of Statistics and Economic Studies (INSEE)
for verification. The register
data returned is public register information and is cached locally so repeat lookups need no new API call.
Note that for a sole trader the register data is personal data (the name is the person’s
name and the registered address may be a home address), and mention the INSEE lookup in your site’s
privacy policy where required.

Support & updates

Clean, well-documented code that’s easy to maintain. Localization-ready out of the box. Built to follow
Gravity Forms’ official add-on framework and Settings API conventions, so it stays compatible as your
stack evolves.

Changelog

1.0.0

  • SIRET / SIREN form field in the “e-Invoicing Fields” group, with a per-field
    identifier-type selector and grouped block input including paste-splitting.
  • Two-step validation: local Luhn checksum (incl. the La Poste exception)
    followed by an online lookup against the INSEE Sirene API v3.11.
  • Reusable, dependency-free lookup library with a 35-day cache in a self-managed
    database table and/or a Gravity Forms form (written via the GFAPI).
  • Register data returned and cached: name, trade name, legal form, APE/NAF code, enterprise
    category, founding date, administrative status, head-office flag and full address.
  • Selectable cache table (own table, an existing schema-compatible table, or no
    database cache).
  • Importable response form using the plugin’s own SIRET field, a date field for the
    founding date and an address field for the address.
  • Reusable siren and siret Settings API field types.
  • Optional “must be active” rule; an unavailable service never blocks a
    submission.
  • Gravity Forms logging support; English, German and French translations.