🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms Cloudflare R2 Integration Add-on

Updated 6 min read Gravity Forms Files, Storage & Databases
On this page
  1. Step 1: Creating an R2 Bucket and API Token in Cloudflare
  2. Step 2: Configuring Global Cloudflare R2 Settings in WordPress
  3. Step 3: Creating and Configuring a Cloudflare R2 Storage Feed
  4. Step 4: Field Mapping & S3 Object Key Architecture
  5. S3 Path Hierarchy
  6. Step 5: Privacy, Data Security & Egress Zero-Cost Advantage
  7. Step 6: Conditional Logic Configuration
  8. Step 7: Developer PHP Filter & Action Hooks
  9. Step 8: HTTP Diagnostic Error Matrix & Troubleshooting
  10. Frequently Asked Questions
  11. Does this add-on support multi-file upload fields?
  12. Can I make uploaded files publicly accessible via a custom domain?
  13. Is local file deletion reversible?
  14. Related Resources & Official Links
  15. Offload Gravity Forms Attachments to Cloudflare R2

Official technical implementation and offload configuration guide for the Gravity Forms Cloudflare R2 Integration Add-on. Learn how to connect Cloudflare S3-compatible credentials, offload form file uploads to R2 buckets with zero egress fees, configure automatic local file deletion, deploy conditional logic, and utilize developer filter hooks.

System Requirements & Prerequisites

  • WordPress Core: Version 5.8 or higher
  • Gravity Forms: Version 2.5 or higher (Basic, Pro, or Elite License)
  • PHP Runtime: Version 7.4, 8.0, 8.1, 8.2, or 8.3 with hash_hmac extension enabled
  • Cloudflare Account: Active account with R2 subscription enabled (10GB free monthly storage)
  • Plugin License: Gravity Forms Cloudflare R2 Add-on installed and active

Step 1: Creating an R2 Bucket and API Token in Cloudflare

Cloudflare R2 provides an S3-compatible API that eliminates bandwidth egress costs. To authenticate programmatic uploads:

  1. Log into your account dashboard at Cloudflare.com.
  2. Select R2 from the primary navigation sidebar.
  3. Click Create bucket. Enter an identifiable name in lowercase letters without spaces (e.g. gf-form-attachments). Choose your preferred bucket jurisdiction (Automatic or EU) and click Create Bucket.
  4. In the right-hand panel under Account Details, locate and copy your 32-character Account ID (e.g. 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d).
  5. Click Manage R2 API Tokens on the R2 Overview page.
  6. Click Create API token. Assign permissions:
    • Permissions: Choose Object Read & Write.
    • Bucket scope: Select Specific bucket and choose your newly created bucket.
  7. Click Create API Token. Copy the generated Access Key ID and Secret Access Key immediately.

Step 2: Configuring Global Cloudflare R2 Settings in WordPress

Store your global R2 S3 credentials within the WordPress administrative panel:

  1. In WordPress, navigate to Forms → Settings.
  2. Click on the Cloudflare R2 tab.
  3. Input your credentials into the corresponding fields:
    • Access Key ID: Paste the R2 Access Key ID generated in Step 1.
    • Secret Access Key: Paste the R2 Secret Access Key.
  4. Click Save Settings. Credentials are saved encrypted in the WordPress options table.
Important Configuration Notice:

Cloudflare R2 utilizes standard AWS Signature Version 4 (AWS4-HMAC-SHA256) protocols. The add-on contains a lightweight, self-contained native signing engine that operates without demanding heavy external AWS SDK library dependencies on your server.

Step 3: Creating and Configuring a Cloudflare R2 Storage Feed

Configure automated file offloading on individual forms by establishing dedicated feeds:

  1. Go to Forms → Forms and click to edit your target form containing a File Upload field.
  2. Hover over Settings at the top bar and select Cloudflare R2.
  3. Click Add New to launch the feed setup editor.
  4. Enter a descriptive Name (e.g., Resume Document Offload).
  5. In R2 Bucket Name, enter your exact Cloudflare bucket name (e.g. gf-form-attachments).
  6. In Account ID Endpoint, enter your 32-character Cloudflare Account ID. The add-on constructs the S3 endpoint URL: https://[account-id].r2.cloudflarestorage.com.
  7. In GF Form Field containing File Upload, select the target file upload field from the dropdown. Both single-file and multi-file upload fields are supported.
  8. Delete Local File After Offload: Check this option if you wish to permanently purge the physical uploaded file from your local WordPress server disk (/wp-content/uploads/gravity_forms/) once the upload to Cloudflare R2 succeeds.
  9. Click Save Settings to activate your feed.

Step 4: Field Mapping & S3 Object Key Architecture

When a submission containing file uploads is received, the add-on reads the physical file path, calculates the SHA-256 binary hash, signs the AWS V4 authorization header, and dispatches an HTTP PUT request directly into your bucket:

Feed Parameter Data Type Required Description
feed_name Text Yes Internal administrative identifier for feed management.
space_name Text Yes Target Cloudflare R2 bucket name where objects will be stored.
region Text (Account ID) Yes Cloudflare 32-character Account ID forming the S3 base URL.
file_upload_field Field Dropdown Yes Target Gravity Forms file upload field containing attachment URLs.
delete_local Checkbox No When checked, calls PHP unlink() to delete the local file upon confirmed HTTP 200 upload.

S3 Path Hierarchy

Files uploaded to your R2 bucket follow an organized chronological hierarchy based on submission timestamp:

/[bucket_name]/[YYYY]/[MM]/[original_filename.ext]

Step 5: Privacy, Data Security & Egress Zero-Cost Advantage

Cloudflare R2 provides profound architectural advantages over traditional cloud providers like Amazon AWS S3 or Google Cloud Storage:

  • Zero Egress Bandwidth Fees: Standard cloud providers charge $0.09 per gigabyte of outbound traffic when downloading attachments. Cloudflare R2 enforces $0 egress fees worldwide, eliminating unexpected bandwidth billing spikes.
  • Server Storage Optimization: High-traffic WordPress websites that collect documents, resumes, and high-resolution photo attachments rapidly exceed server disk quotas. Offloading files and checking Delete Local File After Offload keeps hosting disk usage lean.
  • Bucket Access Control: By default, R2 buckets are private. Objects can only be retrieved by authenticated API credentials or through an optional custom domain CDN proxy configured in your Cloudflare dashboard.

Step 6: Conditional Logic Configuration

Control when files are offloaded based on user form inputs:

  1. Inside your Cloudflare R2 Feed settings, navigate to the Conditional Logic panel.
  2. Enable conditional execution rules. For example:
    • Execute feed if: File Upload Field is not empty.
    • Execute feed if: Application Type is Candidate Resume.
  3. When conditional logic rules evaluate to false, files remain in standard local storage without consuming R2 API write operations.

Step 7: Developer PHP Filter & Action Hooks

Developers can hook into the post-upload lifecycle to record custom metadata or trigger secondary workflows:




functions.php (Post-Upload Action & Custom Logging)
PHP

add_action('gform_after_submission', function($entry, $form) {
    // Example: Log Cloudflare R2 transfer completion in entry notes
    $entry_id = $entry['id'];
    GFFormsModel::add_note(
        $entry_id,
        0,
        'Cloudflare R2 Verification',
        sprintf('R2 transfer verification processed for Entry #%d at %s', $entry_id, current_time('mysql'))
    );
}, 25, 2);

Step 8: HTTP Diagnostic Error Matrix & Troubleshooting

If an upload operation fails, the plugin records an error status code inside the Entry Notes screen (Forms → Entries → [View Entry] → Notes):

Status Code Diagnostic Cause Resolution Action
HTTP 200 OK Object Stored Successfully File successfully transferred to Cloudflare R2 bucket.
HTTP 403 SignatureDoesNotMatch Invalid Access Key or Secret Key Verify credentials in Forms → Settings → Cloudflare R2. Check for accidental leading/trailing spaces in the Secret Access Key.
HTTP 404 NoSuchBucket Bucket Name Typo or Wrong Account ID Verify that the bucket name matches the exact name in your Cloudflare dashboard and that the Account ID is accurate.
HTTP 408 Request Timeout Large File Exceeds PHP Execution Limit Increase max_execution_time and upload_max_filesize in your server’s php.ini configuration.
File Not Found Error Upload Directory Permissions Restricted Ensure the web server user has read permissions for /wp-content/uploads/gravity_forms/.

Frequently Asked Questions

Does this add-on support multi-file upload fields?

Yes. The add-on dynamically inspects the mapped field. If the user attaches multiple files, each file is iterated through, signed, and offloaded independently to your R2 bucket.

Can I make uploaded files publicly accessible via a custom domain?

Yes. In your Cloudflare dashboard under R2 → [Your Bucket] → Settings, scroll to Public Access and connect a custom subdomain (e.g. cdn.yourdomain.com). Uploaded files will be instantly accessible globally through Cloudflare’s edge network.

Is local file deletion reversible?

No. If you enable the Delete Local File After Offload checkbox, the add-on permanently removes the file from your local hosting storage once an HTTP 200 response is verified from Cloudflare. Ensure your R2 bucket has versioning enabled if you require accidental deletion protection.

Offload Gravity Forms Attachments to Cloudflare R2

Eliminate hosting storage limits, cut cloud bandwidth egress fees to zero, and secure files with global edge caching.

Still need help?

Our support team answers tickets every day, usually within a few hours.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr