This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Dates on left (nice easy format), cities on right | |
$locations = array( | |
'1st June 2015' => 'Dubai (GMT+4)', | |
'8th July 2015' => 'Budapest (GMT+2)', | |
'1st August 2015' => 'London (GMT+1)', | |
'14th August 2015' => 'Scotland (GMT+1)' | |
); | |
$today = strtotime( 'now' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'gform_pre_render', 'gform_prepopluate_post_type' ); | |
add_filter( 'gform_admin_pre_render', 'gform_prepopluate_post_type' ); | |
function gform_prepopluate_post_type( $form ){ | |
$post_type = 'project'; | |
$order_by = 'title'; | |
$order = 'ASC'; | |
$return = 'title'; // What you want the value to be, title or id | |
$form_id = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
USAGE | |
add_action( 'gform_post_submission', 'mr_remove_form_entries' ); // ALL FORMS | |
add_action( 'gform_post_submission_1', 'mr_remove_form_entries' ); // SPECIFIC FORM (ID = 1 in exmaple) | |
*/ | |
add_action( 'gform_post_submission_1', 'mr_remove_form_entries' ); | |
// Deletes entries from the database on the specified Gravity Forms form(s) | |
function mr_remove_form_entries( $entry ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( "gform_save_field_value", "mr_filter_default_values", 10, 4); | |
// Don't save values when it's the inputs default value | |
function mr_filter_default_values( $value, $lead, $field, $form ) { | |
if (0 == strcmp( $value, $field['defaultValue']) ) { | |
$value = ''; | |
} | |
return $value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
The idea being a user enters their address, and on submission we grab the long & lat for the address | |
from Google and update 2 hidden inputs (which are most likely custom field inputs). You can then use | |
this data to plot pins on a map etc. | |
USAGE | |
add_action( "gform_pre_submission" , "mr_get_longlat_of_address"); // ALL FORMS | |
add_action( "gform_pre_submission_1" , "mr_get_longlat_of_address"); // SPECIFIC FORM (ID = 1 in exmaple) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// USAGE: $form_count['total'] (int) | |
$form_count = RGFormsModel::get_form_counts( 1 ); // 1 = Form ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Usage: You have a questionare. You set the value of each answer in relation to the index+1 in the array below | |
We then correspond each answer to see which result was selected the most then redirect to that page | |
For a tie we just redirect to the top item, this could be customised to select one of the top results | |
*/ | |
add_filter( 'gform_confirmation', 'custom_confirmation', 10, 4 ); | |
function custom_confirmation( $confirmation, $form, $lead, $ajax ){ | |
if( 1 == $form['id'] ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Gravity Forms Validation. Rejects any required input where $_POST value = default input value (ya, placeholders didn't use to exist!) | |
add_filter( 'gform_validation', 'mr_custom_validation' ); | |
function mr_custom_validation( $validation_result ){ | |
$form = $validation_result['form']; | |
foreach( $form['fields'] as &$field ){ | |
if( '1' == $field['isRequired'] && 'checkbox' != $field['type'] ) { | |
if( $field['defaultValue'] == $_POST[ 'input_' . $field['id'] ] ) { | |
$validation_result['is_valid'] = false; | |
$field['failed_validation'] = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Back to top link. Automatically fades in once user has started scrolling | |
function backtotop() { | |
jQuery( window ).scroll(function() { | |
if(jQuery( this ).scrollTop() > 0) { | |
jQuery( '#toTop' ).fadeIn(); | |
} else { | |
jQuery( '#toTop' ).fadeOut(); | |
} | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set the height of the video based on the width & ratio of the video | |
// That way even on mobile devices fancybox will be the size of the video and not have blank space | |
$( window ).resize( function() { | |
var _ratio = 0.56; | |
var _maxWidth = 1500; | |
var _width = $(window).width() - 50; | |
if( _width > _max) { | |
_width = _max; | |
} |
OlderNewer