New on the blog: why AI belongs in the feed →

BrightLeaf Digital Code Snippet Library

Check out our growing library of code snippets for Gravity Forms!

Eleven of these snippets register their own shortcodes. Every tag and attribute is in our Gravity Forms shortcodes reference. Need a Gravity Forms or GravityView shortcode built for you? Try the free shortcode builder.





Like our snippets? You'll 💜 GravityOps!

Results

Goal This snippet adds a checkbox to your workflow steps. When checked the snippet will send the entry, when it is updated, to the workflow step. If the step has conditional logic it will check the logic and do nothing if it doesn't pass. Only one step per workflow can have this setting checked at a time. If the entry …

Goal A production-ready, client-first A/B testing utility designed for WordPress. This utility handles A/B test resolution in the browser, making it fully compatible with page caching (Cloudflare, Varnish, WP Rocket). --- USAGE: GUTENBERG BLOCKS --- 1. Create two blocks in the editor (e.g., two different Buttons). 2. In the "Advanced" sidebar for BOTH blocks, add the class: abtestcontainer-{slug} Example: abtestcontainer-hero-cta …

Goal This snippet adds advanced search capabilities to the entries list page, allowing you to search by multiple criteria with ANY or ALL of the conditions evaluating to true.

Goal This snippet allows you to bulk edit field properties like "Required," "Visibility," "Allow Duplicates" and more. It adds a small floating button to the side of each field. When you click on a button it opens a new tab in the sidebar where you can edit the desired settings. You can also select all, none or exit bulk edit …

Goal By default this code snippet automatically converts the value of a specific text field to uppercase before saving the entry in Gravity Forms. It ensures consistency in formatting and is particularly useful for fields like names, codes, or identifiers that require capitalization. Now also allows numerous other text manipulations and transformations: Case transformations: uppercase, lowercase, title case, camelCase, PascalCase, …

Goal This code snippet ensures that the sum of all child entries in a Gravity Forms nested form does not exceed the total specified in the parent form. It validates the "Amount" field in child entries against the "Total" field in the parent form, preventing over-allocation of resources, budgets, or quotas. Shows a detailed, currency-formatted message if the attempt would …

Goal This code snippet creates a custom {user_role} merge tag for Gravity Forms. It dynamically retrieves the current user's WordPress role(s) and allows you to use this information within form notifications, confirmations, and field values. Usage Available tags: {user_role} — outputs all roles for the current user joined by the separator (default: ", "). {user_role:display} — same as above but …

Goal This JavaScript snippet disables dropdown choices in a Gravity Forms nested form to prevent duplicate selections across child entries within the same batch. When a user selects an option in one child entry, it becomes unavailable in subsequent child entries, ensuring unique selections. JS snippet to be installed on child form. Make sure to replace the parent form id, …

Goal Allows editing of pricing fields in the Gravity Flow inbox entry view, replacing the usual "Pricing fields are not editable" message with the real field input. Configuration Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates. $workflow_form_ids: Update to include the form IDs where pricing fields should be editable. Optionally restrict to …

Goal This snippet adds a widget to your admin dashboard and embeds your selected form in it. Works well with many add ons such as Nested Forms and Populate Anything and Live Merge Tags. Displays a custom confirmation with a link to the entry (opened in a new tab). Can easily reload the form after submissions. Triggers feeds and notifications …

Goal This code snippet ensures that child form submissions in Gravity Forms do not exceed the available balance recorded in a GravityView ledger. It validates disbursal requests against the user's balance, preventing over-allocation of funds across multiple pending and approved submissions. Each array at the top of the snippet is for a different form with it's own ledger. You can …

Goal This code snippet ensures that a single form submission in Gravity Forms does not exceed the available balance recorded in a GravityView ledger. It validates the requested amount against the user's balance and any pending disbursals, preventing over-allocation of funds. The array at the top of the snippet is for a one form. You can use this snippet for …

Goal Use the simple shortcode [export_filtered_entries] to render a button that triggers a CSV download of the entire GravityView dataset matching the current filters/search. Requirements GravityView and Gravity Forms active. The shortcode should be used on a page where a GravityView is present, or provide view_id/form_id via attributes. Notes For filtered exports, the shortcode MUST be placed on the same …

Goal Adds an "Export Layout" button to the Gravity Forms editor that copies a full HTML visual layout of the form to the clipboard, ready to paste straight into a Google Doc. Useful for handing a form's structure to someone who does not have admin access, and for keeping a readable record of how a form was built. Requirements Gravity …

Goal This code snippet adds an "Export Forms as Text" feature to Gravity Forms, allowing administrators to export form structures, confirmations, notifications, and workflow steps as a downloadable text file. This is useful for documentation, backups, or sharing form configurations without requiring JSON exports. Features Adds an Export Forms as Text tab in the Gravity Forms export menu. Allows selection …

Goal Provide a visual representation of field dependencies in the Gravity Forms editor. Make it easy to see where a field is used in conditional logic, calculations, and notifications. Give form editors a way to quickly audit references without opening every field or setting. Requirements User must have 'gform_full_access' capability. Features Color-coded badges for different reference types (conditional logic, calculations, …

Goal This snippet fixes APC's handling of remote URL's in a file upload field. This snippet downloads the remote file and updates the local entry with the new local URL so that APC can access it and add it to the media library and post. This snippet can also be useful without APC when dealing with remote entry creation or …

Goal BrightLeaf Digital GF Form Styler (Feed Add-On) Goal Provide a user-friendly, non-destructive way to style Gravity Forms without writing manual CSS. Allow granular control over form appearance at the global, field-type, and individual field levels. Ensure that styles are only applied when explicitly configured, preserving the theme's natural look by default. Features Integrated UI: A custom styling panel built …

Goal Adds a custom Gravity Flow step type that generates Gravity Forms Coupons dynamically during a workflow. Provides full UI to configure code, name, amount, type, target form, dates, limits, and stackability. Registers a {coupon_code} merge tag which outputs the code created for the entry.

Goal GOAL Adds a powerful "Advanced Conditional Groups" interface to the Gravity Forms editor. Allows for complex, nested "AND" and "OR" logic that isn't possible with standard settings. CONFIGURATION REQUIRED - Must be active alongside the "Gravity Forms Advanced Conditional Logic Runtime Engine" snippet. - Requires Gravity Forms to be installed and active. USAGE 1. Enable this snippet and the …

Goal GOAL Provides the "engine" that makes advanced conditional logic work on your live forms. It handles both real-time showing/hiding of fields in the browser and secure enforcement of those rules when the form is submitted. CONFIGURATION REQUIRED - Must be active alongside the "Gravity Forms Advanced Conditional Logic Editor UI" snippet. - Requires Gravity Forms to be installed and …

Goal Adds "Export Layout" button to Gravity Forms editor that exports form structure as formatted HTML table to clipboard. Includes field labels, types, conditional logic, and Gravity Populate Anything (GPPA) settings for documentation purposes. Usage Navigate to Forms > Edit Form in WordPress admin Click "📋 Export Layout" button in toolbar Script copies formatted table to clipboard Opens new Google …

Goal Creates a visual progress meter that calculates the sum of a specific numeric field from Gravity Forms entries and displays progress toward a goal. Supports filtering by field values, date ranges, and custom multipliers. Configuration CSS: Style .gfpm-container, .gfpm-meter, .gfpm-fill, .gfpm-caption, .gfpm-goal CSS: Set width, colors, borders for progress bar appearance Attributes: form_id, field, and goal are required Usage …

Goal Create a custom merge tag that outputs a secure GravityView Edit Entry link for the current entry when displayed inside a GravityView context. The snippet registers the merge tags: {gview_edit_entry_link} {gview_edit_entry_link:Link Text} These tags generate an edit link to the current entry within the active GravityView. Usage {gview_edit_entry_link:Your Link Text} {gview_edit_entry_link:Update your submission} Default Behavior If no link text …

Goal Creates a new merge tag-available anywhere, not just in standard Gravity Forms areas-that retrieves the specified GET parameter. It will look for "parameter name" in the query strings of the URL and replace the merge tag with the value for that paramater.

Goal Prevents duplicate submissions when a specific combination of fields (Name, Number, Date) matches an existing active entry. If a duplicate is found, shows custom messages on the relevant fields. CONFIGURATION Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates. $forms: Add your form ID as a key, and set the field IDs …

Goal When using Nested Forms, prevent duplicate values across multiple child entries in the same batch/session for specific fields you choose (e.g., a number field, a name field, or a date field). Configuration Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates. $forms_and_fields: Add your child form ID as the key, and list …

Goal This JavaScript snippet prompts users with a confirmation message before submitting a Gravity Form when they select a specific radio button choice. If the user selects a designated choice, a confirmation dialog appears, requiring them to confirm their selection before the form is submitted. This ensures that users intentionally proceed with their chosen option. Remember to update the choices …

Goal This code snippet automatically capitalizes the first letter of each word in specified Gravity Forms fields before saving the entry. It ensures that user inputs, such as names or addresses, are stored in proper case formatting, enhancing data consistency and readability. Configuration Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates. $form_and_field_ids: …

Goal GravityFlow Approval and User Input steps have a little known quirk. Before processing the step (approval, rejection, user input, etc.) they clear the values from fields that are hidden by conditional logic if those fields are marked as editable OR are calculation fields. This snippet adds a multi select field to the bottom of your Approval or User Input …

Goal This code snippet enforces validation on a Gravity Forms Nested Form field, ensuring that at least one child entry in a batch contains a specific value in a selected field. If no child entry meets the requirement, the form submission is blocked, and a validation message is displayed. CONFIGURATION Edit the config block below. Installed through GOCSM, these values …

Goal This code snippet enhances Gravity Flow by allowing workflows to be delayed or restarted based on GravityView approval and subscription payments. It provides options to: Delay workflow initiation until an entry is approved in GravityView instead of starting upon form submission. Restart the workflow upon each subscription payment for recurring payment scenarios. Update a date field when the workflow …

Goal Sends email notification to administrators whenever any form submission fails validation. Captures all failed fields with their labels and error messages, helping identify problematic forms, confusing validation rules, or user experience issues that need attention. Configuration Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates. $to: Add the recipient email address (in …

Goal Alerts administrators when Gravity Forms fails to send email notifications. Critical for ensuring important notifications (confirmations, alerts, assignments) aren't silently lost. Includes full email details and error message to help diagnose SMTP/email configuration issues. Configuration Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates. $to: Add recipient email address in $to variable …

Goal Monitors Gravity Flow workflows and alerts administrators when workflow fails to start after form submission. Critical for catching workflow configuration errors, conditional logic issues, or system failures that prevent automated processes from running. Checks both parent and nested child forms. Configuration Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates. $to: Add …

Goal Monitors donation/ledger forms for critical fields that have zero or empty values after submission. Sends email alert to administrators when amount fields are empty, which could indicate data loss, calculation errors, or payment processing issues. Includes user info and timestamp for debugging. Configuration Edit the config block below. Installed through GOCSM, these values are fields and survive snippet updates. …

Goal This snippet updates a post created by APC when the entry is updated.

Goal This snippet ensures that specific groups of fields within a Gravity Forms form do not contain duplicate values. It allows you to define multiple sets of fields for validation, ensuring that no two fields within a group share the same value. If duplicates are found, a custom validation error message is displayed for each affected field. Configuration Edit the …