Gravity Forms
Structured form handling and transactional input for WordPress. Gravity Forms serves as the primary data collection endpoint in the Gravity stack, feeding entries into SMTP delivery, GravityView display, Gravity Connect AI processing, and GravityKit workflows.
When to use
- Installing, updating, or verifying Gravity Forms or official add-ons via
wp gf - Managing forms and entries from the command line
- Version-controlling form definitions as JSON
- Testing notifications and confirmations
- Configuring anti-spam for AI bots (Cloudflare Turnstile)
- Writing
GFAPI-based PHP (not direct DB writes) - Serializing form schemas for MCP/AI pipelines
Official documentation
GitHub
| Repo | Purpose |
|---|---|
gravityforms/gravityformscli |
Official WP-CLI add-on (wp gf commands) |
gravitywiz/snippet-library |
1000+ community hooks and filters for AI training |
Procedure
0) Guardrails
- Always use
GFAPI— never write directly towp_rg_lead_*tables - Set
GF_LICENSE_KEYinwp-config.php, not as a CLI argument - After any install/update, run
wp gf setup --forceto apply DB migrations - Run
wp gf version gravitysmtpand check CVE-2026-4020 — seewp-gravity-smtpskill
1) Install and verify
# Requires GF_LICENSE_KEY constant in wp-config.php:
# define('GF_LICENSE_KEY', 'your-key-here');
wp gf install --force --activate
wp gf install gravityformscli --activate
wp gf install gravitysmtp --activate # ⚠️ verify version ≥ 2.1.5 immediately
wp gf install gravityformsturnstile --activate
wp gf install gravityformsuserregistration --activate
wp gf install gravityformswebhooks --activate
wp gf setup --force
wp gf version
2) Form management
wp gf form list --active --format=table
wp gf form export 1 --path=./forms/contact-form.json # commit to git
wp gf form import ./forms/contact-form.json
wp gf form duplicate 1
# Export all forms
mkdir -p forms
for id in $(wp gf form list --format=ids); do
wp gf form export $id --path=forms/form-${id}.json
done
3) Entry management
wp gf entry list --form_id=1 --status=active --format=table
wp gf entry get 42 --format=json
wp gf entry export 1 --dir=./exports --format=csv
wp gf entry export 1 --dir=./exports --start_date=2026-01-01
wp gf entry notification get 42 --event=form_submission # test notifications
4) GFAPI — correct PHP patterns
// ✅ Always use GFAPI
$entry = GFAPI::get_entry($entry_id);
$form = GFAPI::get_form($form_id);
$result = GFAPI::add_entry($entry_data);
GFAPI::update_entry($entry);
// ❌ Never write directly to wp_rg_lead_* tables
global $wpdb;
$wpdb->update('wp_rg_lead', [...]); // never
5) MCP-compatible JSON schema
$form = GFAPI::get_form(1);
$schema = ['form_id' => $form['id'], 'title' => $form['title'],
'fields' => array_map(fn($f) => [
'id' => $f->id, 'label' => $f->label,
'type' => $f->type, 'required' => $f->isRequired,
'choices' => $f->choices ?? null,
], $form['fields'])];
file_put_contents(ABSPATH . 'llms-form-schema.json', json_encode($schema, JSON_PRETTY_PRINT));
6) Anti-spam for AI bots
wp gf install gravityformsturnstile --activate
# Configure: Forms → Settings → Turnstile → "Managed" mode
7) Remote management (WP Engine)
wp @production gf check-update
wp @production gf update
wp @production gf setup --force --skip-plugins --skip-themes
wp @production cache flush --skip-plugins --skip-themes
Agent scripts
bash {baseDir}/scripts/gf-inspect.sh # local audit
bash {baseDir}/scripts/gf-inspect.sh --remote # WP Engine via SSH
References
references/gravity-forms-cli.md— Fullwp gfcommand referencewp-gravity-smtpskill — SMTP delivery and CVE-2026-4020wp-gravity-connectskill — OpenAI integrationwp-gravityviewskill — Front-end entry displaywp-gravity-wizskill — Spellbook, Perks, GP Populate Anythingwp-wpcli-and-opsskill — General WP-CLI patterns