Skip to content

Instantly share code, notes, and snippets.

@spivurno
spivurno / gp-auto-login-bypass-custom-login-system.php
Created May 19, 2015 15:22
GP Auto Login // Gravity Perks // Bypass Custom Login System
<?php
/**
* GP Auto Login // Gravity Perks // Bypass Custom Login System
*/
add_action( 'gpal_pre_auto_login', function() {
remove_filter( 'authenticate', array( $GLOBALS['CAS_Maestro'], 'validate_login' ), 30, 3 );
remove_filter( 'login_url', array( $GLOBALS['CAS_Maestro'], 'bypass_reauth' ) );
} );
@spivurno
spivurno / gw-gravity-forms-save-and-continue-refresh-default-value.php
Last active August 29, 2015 14:22
Gravity Wiz // Gravity Forms // Force Field with Default Value to Refresh on Save & Continue
/**
* Gravity Wiz // Gravity Forms // Force Field with Default Value to Refresh on Save & Continue
*/
add_action( 'gform_submission_values_pre_save', function( $values, $form ) {
// update "12" to the ID of your desired form
if( $form['id'] == 12 ) {
// update "4" to the field ID that should be refreshed on save & continue
$values[4] = false;
}
@spivurno
spivurno / gp-auto-login-redirect-to-custom-url.php
Created June 16, 2015 14:09
Gravity Perks // GP Auto Login // Redirect to Custom URL on Auto Login
/**
* Gravity Perks // GP Auto Login // Redirect to Custom URL on Auto Login
*/
add_filter( 'gpal_auto_login_on_redirect_redirect_url', function( $url, $user_id ) {
$url = 'http://mysite.com/my-custom-url/';
return $url;
}, 10, 2 );
@spivurno
spivurno / gp-limit-choices-modify-out-of-stock-message.php
Created July 30, 2015 12:43
GP Limit Choices // Gravity Perks // Modify the "Out of Stock" Message
<?php
/**
* GP Limit Choices // Gravity Perks // Modify the "Out of Stock" Message
*/
add_filter( 'gplc_out_of_stock_message', function( $not_enough_stock_message, $form, $field, $inventory_data ) {
return 'Sorry, friends. This item is no longer avialable.';
}, 10, 4 );
// only apply to form ID 1
add_filter( 'gplc_out_of_stock_message_1', function( ) { /* custom code */ }, 10, 4 );
<?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 / gw-remove-price-from-option-labels.js
Created September 29, 2015 01:21
Gravity Wiz // Gravity Forms // Remove Price from Option Labels
<script type="text/javascript">
function gform_format_option_label( fullLabel, fieldLabel, priceLabel, selectedPrice, price, formId, fieldId ) {
return fieldLabel;
}
</script>
@spivurno
spivurno / gp-auto-login-redirect-to-new-site.php
Created February 25, 2015 14:56
Gravity Perks // GP Auto Login // Redirect to New Site on Auto Login
/**
* Gravity Perks // GP Auto Login // Redirect to New Site on Auto Login
*/
add_filter( 'gpal_auto_login_on_redirect_redirect_url', function( $url, $user_id ) {
require_once( GFUser::get_base_path() . '/data.php' );
$entry_id = get_user_meta( $user_id, 'entry_id', true );
$site_id = GFUserData::get_site_by_entry_id( $entry_id );
@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 / 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));