Skip to content

Instantly share code, notes, and snippets.

@chrisegg
chrisegg / gforms_to_gutenberg_table_block.php
Created December 18, 2025 03:43
Replaces Gravity Forms post content with a real Gutenberg Table block, dynamically populated using form field values via merge tags.
<?php
/**
* Title: Gravity Forms → Gutenberg Table Block Output
* Description: Replaces Gravity Forms post content with a real Gutenberg Table block,
* dynamically populated using form field values via merge tags.
* Author: Chris Eggleston
*
* How to Use:
* 1. Update the form ID check to match your target form.
@chrisegg
chrisegg / change_role_expired_memberships.php
Created December 12, 2025 17:16
This cron-based code runs daily and automatically changes any user with an expired membership_expiration date from the "member" role to the "subscriber" role.
<?php
/**
* Change Role for Expired Memberships
*
* This cron-based code runs daily and automatically changes any user with an expired membership_expiration date from the
* "member" role to the "subscriber" role.
*
*
*
@chrisegg
chrisegg / membership_experation_date_calculator.php
Last active December 12, 2025 17:02
Automatically calculate the correct expiration date based on product term for new members.
<?php
/**
* Membership Expiration Date Calculation
*
* When someone submits Form 7 and picks a 1-, 2-, or 3-year membership option (field 10), this code creates a brand-new
* membership that starts today and expires exactly that many years in the future, then puts the expiration date into hidden
* field 16 so it gets saved to the user’s profile.
*
* Usage: Change the form and field ID numbers to match those used in your form.
@chrisegg
chrisegg / membership_renewal_calculation.php
Created December 12, 2025 16:48
Automatically calculate the correct new expiration date based on product term and current membership term and status
<?php
/**
* Membership Renewal Calculation
*
* When a logged-in user submits the membership renewal form (ID 1), automatically calculate the correct new expiration date,
* extending from their current expiration if active, or from today if expired, based on whether they chose a 1, 2, or 3-year
* renewal, and save it to their user profile.
*
* Usage: Change the form and field ID numbers to match those used in your form.
@chrisegg
chrisegg / gravity-forms-list-filed-placeholder..js
Created October 3, 2025 13:09
Add placeholder text to a Gravity Forms list field, supports single field or multiple columns.
/**
* Description: Add placeholder text to Gravity Forms list fields.
* Version: 1.0
* Author: Chris Egglelston
* Website: https://gravityranger.com
*/
<script>
const gfListPlaceholderConfig = {
formId: 401, //replace 401 with your forms ID
@chrisegg
chrisegg / gravity-forms-entries-unread-indicator.php
Created January 23, 2025 22:14
Adds a unread indicator to Gravity Forms entries menu in the WordPress admin.
<?php
/**
* Plugin Name: Gravity Forms Unread Entries Indicator
* Description: Adds an indicator to the Gravity Forms Entries menu showing the number of unread entries.
* Version: 1.0
* Author: Chris Egglelston
* Website: https://gravityranger.com
*/
if (!defined('ABSPATH')) {
@chrisegg
chrisegg / generateblocks-popup-modal.css
Last active January 6, 2025 03:03
This JavaScript code creates a popup modal functionality for GenerateBlocks blocks.
.hidden-block {
display: none;
}
.hidden-block.show {
display: block;
}
.popup-modal {
display: none; /* Hidden by default */
position: fixed;
@chrisegg
chrisegg / gravity-forms-show-field-id.js
Created January 4, 2025 16:41
This script dynamically adds custom-styled Field IDs to all fields (next to the label) in the Gravity Forms editor, allowing administrators to easily identify field IDs.
/**
* Gravity Forms Field ID Display
* Author: Chris Eggleston
* Version: 1.1
*
* Description: This script dynamically adds custom-styled Field IDs to all fields in the Gravity Forms editor,
* allowing administrators to easily identify field IDs.
*
* How to use:
* - Include this script on pages where the Gravity Forms editor is loaded.
@chrisegg
chrisegg / gf_shortcode_show_remaining_entry_number.php
Last active March 14, 2025 01:04
This shortcode dynamically calculates and displays the remaining availability entries for a Gravity Forms form based on the number of form entries submitted and the entry limit settings.
<?php
/**
* Entries Remaining Shortcode
*
* This shortcode dynamically calculates and displays the remaining availabile entries
* for a Gravity Forms form based on the number of form entries submitted.
*
* Usage: Enable entry limits in form settings and set your limit number. Then add the shortcode [spots_available] to an
* HTML field in your form or to a WordPress post or page where a Gravity Form is embedded.
*
@chrisegg
chrisegg / gr-change-entry-date-metabox.php
Last active February 5, 2025 23:49
Change the entry date with a new meta box in the entry details page.
<?php
/**
* Plugin Name: Gravity Forms Change Entry Date
* Plugin URI: https://gravityranger.com/gravity-forms-changing-the-entry-date
* Description: Adds a meta box to Gravity Forms entry details page allowing admins to change the entry date.
* Version: 1.0
* Author: Chris Eggleston
* Author URI: https://gravityranger.com
* License: GPL-2.0+
*/