Skip to content

Instantly share code, notes, and snippets.

@spivurno
spivurno / gw-gravity-forms-shortcode-attr-field-props.php
Last active October 26, 2021 15:27
Gravity Wiz // Gravity Forms // Custom Field Properties via [gravityforms] Shortcode
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-shortcode-attr-field-props.php
*/
/**
* Gravity Wiz // Gravity Forms // Custom Field Properties via [gravityforms] Shortcode
*
* Provide a custom "field_groups" attribute for the [gravityforms] shortcode. This allows you to modify field
@spivurno
spivurno / gp-media-library-auto-add-custom-field-for-file-id.php
Created August 11, 2017 12:58
Gravity Perks // GP Media Library // Auto-add Custom Field for File ID
<?php
/**
* Gravity Perks // GP Media Library // Auto-add Custom Field for File ID
* http://gravitywiz.com/documentation/gp-media-library/
*/
add_filter( 'gform_post_data', function( $data, $form, $entry ) {
if( ! is_callable( 'gp_media_library' ) ) {
return $data;
}
@spivurno
spivurno / gp-copy-cat-copy-label.html
Last active November 29, 2021 19:42
Gravity Perks // GP Copy Cat // Copy Label (instead of Value)
<!--
Gravity Perks // GP Copy Cat // Copy Label (instead of Value)
http://gravitywiz.com/documentation/gravity-forms-copy-cat/
Instructions:
1. Add an HTML field to your form.
2. Copy and paste the entire contents of this snippet into the "Content" field setting.
-->
<script>
gform.addFilter( 'gppc_copied_value', function( value, $elem, data ) {
@spivurno
spivurno / gw-gravity-forms-time-sensitive-choices.php
Last active August 14, 2020 19:24
Gravity Wiz // Gravity Forms // Time Sensitive Choices
<?php
/**
* Gravity Wiz // Gravity Forms // Time Sensitive Choices
*
* Provide a drop down of times and automatically filter which choices are available based on the current time.
*
* @version 1.1
* @author David Smith <[email protected]>
* @license GPL-2.0+
* @link http://gravitywiz.com/...
@spivurno
spivurno / gw-gravity-forms-get-form-id-by-name.php
Created July 11, 2017 20:09
Gravity Wiz // Gravity Forms // Get Form ID by Form Name
<?php
/**
* Gravity Wiz // Gravity Forms // Get Form ID by Form Name
*
* @param $name string The name of the form.
*
* @return int The form ID.
*/
function gw_get_form_id_by_name( $name ) {
global $wpdb;
@spivurno
spivurno / gp-post-content-merge-tags-replace-merge-tags-template.php
Created July 2, 2017 13:56
Gravity Perks // GP Post Content Merge Tags // Replace Merge Tags via Code
<?php ob_start(); ?>
ALL TEMPLATE CODE GOES HERE, INSIDE THE OUTPUT BUFFER.
<?php
echo gp_post_content_merge_tags()->replace_merge_tags( ob_get_clean() );
@spivurno
spivurno / gp-notification-scheduler-cc-expiration.php
Created July 1, 2017 14:45
Gravity Perks // GP Notification Scheduler // Credit Card Expiration
<?php
/**
* Gravity Perks // GP Notification Scheduler // Credit Card Expiration
*
* Send notifications based on a credit card expiration date.
*
* @version 0.1
* @author David Smith <[email protected]>
* @license GPL-2.0+
* @link http://gravitywiz.com/
@spivurno
spivurno / gw-gravity-forms-user-registration-update-by-email.php
Last active November 5, 2021 12:47
Gravity Wiz // Gravity Forms // User Registration // Update by Email
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-user-registration-update-by-email.php
*/
/**
* Gravity Wiz // Gravity Forms // User Registration // Update by Email
*
* Create User Registration feeds that will update the user by the submitted email address, allowing non-logged-in users
@spivurno
spivurno / gw-gravity-forms-display-prices-for-choice-based-product-fields.php
Last active May 19, 2023 21:48
Gravity Wiz // Gravity Forms // Display Price for Drop Down and Radio Button Product Fields
<?php
/**
* Gravity Wiz // Gravity Forms // Display Price for Drop Down and Radio Button Product Fields
* http://gravitywiz.com/
* Source: https://www.gravityhelp.com/documentation/article/gform_field_choice_markup_pre_render/#2-include-price-for-product-fields
*/
add_filter( 'gform_field_choice_markup_pre_render', function ( $choice_markup, $choice, $field, $value ) {
if ( $field->type == 'product' ) {
$new_string = sprintf( '>%s - %s<', $choice['text'], GFCommon::to_money( $choice['price'] ) );
@spivurno
spivurno / gw-gravity-forms-populate-form.php
Last active March 20, 2025 16:33
Gravity Wiz // Gravity Forms // Populate Form with Entry (Optionally Update Entry on Submission)
<?php
/**
* Gravity Wiz // Gravity Forms // Populate Form with Entry (Optionally Update Entry on Submission)
*
* Pass an entry ID and populate the form automatically. No form configuration required. Optionally update the entry on
* submission.
*
* @version 1.5
* @author David Smith <[email protected]>
* @license GPL-2.0+