Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter("gform_pre_render", "populate_dropdown");
function populate_dropdown($form){
global $current_user;
get_currentuserinfo();
foreach($form['fields'] as &$field) {
if($field['inputName'] == 'email') {
@spivurno
spivurno / gist:3708032
Created September 12, 2012 16:47
Gravity Wiz // Populate Date: Year from Current Date
/**
* Populate Date: Year from Current Date
*/
add_filter('gform_field_value_year_from_date', 'gw_year_from_date');
function gw_year_from_date() {
return date('m/d/Y', strtotime('+1 year'));
}
@spivurno
spivurno / gw-gravity-forms-populate-date-year-from-today.php
Last active September 23, 2022 15:53
Gravity Wiz // Populate Date: Year from Current Date
<?php
/**
* Populate Date: Year from Current Date
*/
add_filter('gform_field_value_year_from_date', 'gw_year_from_date');
function gw_year_from_date() {
return date('Y-m-d', strtotime('+1 year'));
}
@spivurno
spivurno / conditionalconfirmations.php
Last active October 10, 2015 14:58
Gravity Wiz // Conditional Confirmations
<?php
/**
* Conditional Confirmations (with Merge Tag Support)
* http://gravitywiz.com/2012/08/18/conditional-confirmations/
*
* Provides the ability to register conditional confirmations. To register a new conditional confirmation
* use the GWConditionalConfirmations::add_conditional_confirmation() function.
*
* GWConditionalConfirmations::add_conditional_confirmation($form_id, $field_id, $operator, $value, $confirmation);
@spivurno
spivurno / gist:3708552
Last active October 10, 2015 15:07
Gravity Wiz // Conditional Confirmations: Examples
<?php
// example for form ID 7 where the confirmation will redirect the user to http://google.com if the value of field ID 3 is less than 10
GWConditionalConfirmations::add_conditional_confirmation(7, 3, 'less_than', 10, array('redirect' => 'http://google.com'));
// example for form ID 5 where a text confirmation will be displayed if field ID 2 is equal to "Virginia"
GWConditionalConfirmations::add_conditional_confirmation(5, 2, 'is', 'Virginia', 'Confirmed! You are from Virginia!');
// example for form ID 11 where the confirmation will redirect to the WordPress page ID 12 if the value of field ID 4 is greater than 500
GWConditionalConfirmations::add_conditional_confirmation(11, 4, 'greater_than', 500, array('page' => 12));
@spivurno
spivurno / gw-gravity-forms-better-pre-submission-confirmation.php
Last active September 23, 2022 15:50
Gravity Wiz // Gravity Forms // Better Pre-submission Confirmation
<?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-better-pre-submission-confirmation.php
*/
/**
* Better Pre-submission Confirmation
* http://gravitywiz.com/2012/08/04/better-pre-submission-confirmation/
*/
@spivurno
spivurno / gist:3708669
Created September 12, 2012 18:02
Gravity Wiz // Require All Columns of List Field
<?php
/**
* Require All Columns of List Field
* http://gravitywiz.com/2012/07/23/require-all-columns-of-list-field/
*/
add_filter('gform_validation', 'gwiz_require_all_list_columns');
function gwiz_require_all_list_columns($validation_result) {
@spivurno
spivurno / gw-gravity-forms-random-field-order.php
Last active November 26, 2020 13:10
Gravity Wiz // Gravity Forms // Random Field Order
<?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-random-fields.php
*/
/**
* Gravity Wiz // Gravity Forms // Random Fields
*
* Randomly display a specified number of fields on your form.
@spivurno
spivurno / gist:3708752
Created September 12, 2012 18:12
Gravity Wiz // Limit How Many Checkboxes Can Be Checked
<?php
/**
* Limit How Many Checkboxes Can Be Checked
* http://gravitywiz.com/2012/06/11/limiting-how-many-checkboxes-can-be-checked/
*/
class GFLimitCheckboxes {
public static $field_limits;
@spivurno
spivurno / gw-gravity-forms-list-field-rows-by-field-value.php
Last active July 27, 2020 20:07
Gravity Wiz // Set Number of List Field Rows by Field Value
<?php
/**
* Gravity Wiz // Gravity Forms // Set Number of List Field Rows by Field Value
*
* Add/remove list field rows automatically based on the value entered in the specified field. Removes the add/remove
* that normally buttons next to List field rows.
*
* @version 1.3
* @author David Smith <[email protected]>
* @license GPL-2.0+