BrightLeaf Digital Code Snippet Library

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





Like our snippets? You'll 💜 GravityOps!

GOAL Adds category slugs as CSS classes to the body tag on single posts and category archives, enabling category-specific styling without custom templates. CONFIGURATION None - works out of the box Optional: Add CSS rules targeting .category-{slug} in your theme stylesheet USAGE Access in CSS as: body.category-news { /* styles * / } Example output on single post in "News"

New: The snippet now also supports custom labels for the revert button on an Approval step, as well as Custom Submit Form label, Custom Update label, and Custom Save Progress label for the User Input step. This code snippet enhances Gravity Flow by allowing administrators to customize the text of the "Approve" and "Reject" buttons in an Approval step. Instead

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 Creates a real-time countdown timer displaying days, hours, minutes, and seconds until a specified date. Uses WordPress timezone settings and validates date input. CONFIGURATION CSS: Style classes .countdown-timer, .countdown-segment, .countdown-number, .countdown-label WordPress: Ensure timezone is set correctly in Settings > General Date Format: Must use dd/mm/yyyy format (e.g., 31/12/2025) Accepts an optional end_text to show when the timer countdown

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. Features Adds two merge tags: {user_role} (all roles) and {user_primary_role} (primary role). Automatically retrieves the logged-in user's role(s) and replaces the merge tag with the corresponding

GOAL Creates a tabbed interface by parsing nested div structures into clickable tabs with associated content panels. Supports nested shortcodes and DOM-based parsing. CONFIGURATION CSS: Style .tabbed-content-wrapper, .tabbed-content-tabs, .tab-label, .tab-panel CSS: Define .active class for selected tab and visible panel Structure: Content must follow specific div nesting (see usage) USAGE [tabbed_content]  <div>  <div>Tab 1 Label</div>  <div>Tab 1 content here...</div>  </div>

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, the

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 $workflow_form_ids: Update to include the form IDs where pricing fields should be editable. Optionally restrict to certain pricing field types via $allowed_pricing_types. NOTES Applies only on the Gravity Flow inbox entry view

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 and

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 use

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 as

Goal Show a simple popup based on three common behaviors: Exit intent (when a desktop user moves the mouse toward the browser’s top bar) Idle time (after a visitor hasn’t moved/typed/scrolled for N seconds) After scrolling a specified amount down the page. Keep everything self‑contained: the shortcode prints its own minimal CSS and JS inline. Work nicely with normal page

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. IMPORTANT For filtered exports, the shortcode MUST be placed on the same page

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 of

When Gravity Flow Form Connector creates a new entry, ensure multi‑file upload values are arrays (not JSON strings). Decodes JSON when detected and normalizes the array. This allows the entry to be created without errors.

This snippet has been upgraded to a plugin for easier management and additional functionality. The plugin version also allows creating folders for Gravity View's. More features to come. Check it out here!     The Form Folders snippet allows admins to organize forms into folders for better management. It provides a user-friendly UI to create, view, rename, and delete folders,

GFSearch This snippet has been replaced with a plugin version.

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 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 Creates a mobile-friendly accordion component that parses nested divs into collapsible sections. Supports nested shortcodes and allows only one section to be open at a time. CONFIGURATION CSS: Add styles for .mobile-accordion-wrapper, .accordion-section, .accordion-label, .accordion-content CSS: Define .open and .visible classes for active states Structure: Content must follow specific format (see usage below) USAGE [mobile_accordion] <div>  <div>Section 1 Title</div>  <div>Section

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 $forms: Add your form ID as a key, and set the field IDs to check. Then set the corresponding error messages. Optionally set the window_days key to limit check

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 $forms_and_fields: Add your child form ID as the key, and list the child field IDs you want to keep unique with the message users should see if

BrightLeaf Pricing Table — Single-File Shortcode Snippet Goal Make it easy to add a clear, modern pricing table to any page with simple shortcodes. Keep everything in one place: the layout, styles, and behavior live in this single file. Optionally connect to Freemius for checkout and automatically load your plans and prices. Features Clean pricing cards with a Monthly/Annual toggle.

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 and messages

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. Features Automatically applies proper case (capitalizes the first letter of each word). Works on specified form and field

GOAL This code snippet renames the "Workflow Complete" step in Gravity Flow by dynamically replacing it with the actual name of the last completed step in the workflow. This ensures that users see a meaningful step name rather than the generic "Workflow Complete" label when viewing GravityView entries. CONFIGURATION $form_ids: Update to the list of form IDs this should apply to. NOTES

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 $forms: nested_field_id: ID of the Nested Form field on the parent

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 restarts to reflect the latest payment or approval. Manually

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 $to: Add the recipient email address (in between the quotes) where notifications should be sent. Defaults to site admin email. $whitelist: Choose which

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. DISCLAIMER This snippet only catches notifications that Gravity Forms detected as failed. It does not catch errors that occur during email sending, such as SMTP

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. FEATURES INCLUDED ✓ Workflow configuration details ✓ Conditional logic evaluation (shows if conditions are met/not met and why) ✓

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 $to: Add the recipient email address (in between the quotes) where notifications should be sent. Defaults

This snippet enhances the Update Entry and Create Entry workflow steps in Gravity Flow by allowing a field value to be automatically saved as an entry note. The note is recorded when a new entry is created or an existing entry is updated via workflow automation. Features ✔ Save Field Value as Entry Note – Select a field whose value should be recorded as a note when the workflow

GOAL Keeps a designated field (label default: "Workflow Step Field") up to date with the workflow status: On step start: current step name On workflow complete: complete step name On workflow cancel: "Cancelled" CONFIGURATION $status_field_label: If you use a different field label, change to your field label.

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. Features ✔ Prevents Duplicate Values – Ensures that no