Skip to content

Instantly share code, notes, and snippets.

Richard Wawrzyniak richardW8k

Block or report user

Report or block richardW8k

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@richardW8k
richardW8k / RW_Button_Field.php
Last active Nov 12, 2018
Adds a Button field type allowing you to add extra buttons to the form, supported type are button, submit and reset.
View RW_Button_Field.php
<?php
/**
* Plugin Name: Gravity Forms - Button Field
* Last Modified: 22/06/2014
*/
class RW_Button_Field {
function __construct() {
if( ! property_exists( 'GFCommon', 'version' ) || ! version_compare( GFCommon::$version, '1.8', '>=' ) )
@richardW8k
richardW8k / change_col_to_checkboxes.php
Created May 3, 2014
To convert a list field column to use checkboxes add the php excluding the first line to your theme functions.php file. The JavaScript can be placed between script tags in a HTML field on the form.
View change_col_to_checkboxes.php
<?php
// format: gform_column_input_content_FORMID_FIELDID_COLUMN
add_filter( 'gform_column_input_content_524_2_2', 'change_column_to_checkbox', 10, 6 );
function change_column_to_checkbox( $input, $input_info, $field, $text, $value, $form_id ) {
$input_field_name = "input_{$field['id']}[]";
$tabindex = GFCommon::get_tabindex();
$new_input = "<div class='ginput_container'><ul class='gfield_checkbox'>" .
"<li><input type='checkbox' {$tabindex} value='First Choice' /><label>First Choice</label></li>" .
"<li><input type='checkbox' {$tabindex} value='Second Choice' /><label>Second Choice</label></li>" .
"</ul><input type='hidden' name='{$input_field_name}' value='' /></div>";
@richardW8k
richardW8k / change_column_to_checkbox.php
Created May 3, 2014
To convert a list field column to use a checkbox add the php excluding the first line to your theme functions.php file. The JavaScript can be placed between script tags in a HTML field on the form.
View change_column_to_checkbox.php
<?php
// format: gform_column_input_content_FORMID_FIELDID_COLUMN
add_filter( 'gform_column_input_content_524_2_2', 'change_column_to_checkbox', 10, 6 );
function change_column_to_checkbox( $input, $input_info, $field, $text, $value, $form_id ) {
$input_field_name = "input_{$field['id']}[]";
$tabindex = GFCommon::get_tabindex();
$new_input = "<input type='checkbox' {$tabindex} /><input type='hidden' name='{$input_field_name}' value=' ' />";
return $new_input;
}
@richardW8k
richardW8k / rw_change_checkbox_structure.php
Created Mar 19, 2014
change Gravity Forms checkbox structure so it doesn't use the extra ul and li's
View rw_change_checkbox_structure.php
add_filter( 'gform_field_input', 'rw_change_checkbox_structure', 10, 5 );
function rw_change_checkbox_structure($input, $field, $value, $lead_id, $form_id){
$input_type = RGFormsModel::get_input_type($field);
if($input_type != "checkbox" || IS_ADMIN && RG_CURRENT_VIEW == "entry")
return $input;
$choices = "";
if(is_array($field["choices"])){
$choice_number = 1;
@richardW8k
richardW8k / RW_Delete_Entry.php
Last active Nov 10, 2016
When placed in the theme functions.php file this will add a checkbox to the 'Form Options' part of the Form Settings page which when checked will cause entries to be automatically deleted at the end of the submission process.
View RW_Delete_Entry.php
<?php
class RW_Delete_Entry {
function __construct() {
if( ! property_exists( 'GFCommon', 'version' ) || ! version_compare( GFCommon::$version, '1.8.5.8', '>=' ) )
return;
add_filter( 'gform_tooltips', array( $this, 'add_delete_tooltip') );
add_filter( 'gform_form_settings', array( $this, 'add_delete_setting' ), 10, 2 );
add_action( 'gform_pre_form_settings_save', array( $this, 'save_delete_setting' ), 10 );
add_action( 'gform_after_submission', array( $this, 'maybe_delete_form_entry' ), 15, 2 );
@richardW8k
richardW8k / RWNotificationExtras.php
Last active Feb 2, 2018
Adds a new settings to Gravity Forms notifications allowing uploaded files to be attached to the notification and the notification format to be changed to text.
View RWNotificationExtras.php
<?php
/**
* Plugin Name: Gravity Forms - Notification Extras
* Author: Richard Wawrzyniak
* Description: Adds new settings to Gravity Forms Notifications enabling file uploads to be attached to notifications and the notification format to be changed to text.
* Version: 1.0
*
* Last Modified: 17/10/2014
* Updated attach_file() to allow for possibility that uploads folder was changed
* Added suppot for post_image fields
View sum_list_column.php
<?php
add_filter( 'gform_calculation_formula', 'sum_list_column', 10, 4 );
function sum_list_column( $formula, $field, $form, $lead ) {
// {List:1.3} - {Label:ID.Column}
preg_match_all( '/{[^{]*?:(\d+?).(\d+?)}/mi', $formula, $matches, PREG_SET_ORDER );
if( is_array( $matches ) ) {
foreach( $matches as $match ) {
@richardW8k
richardW8k / rw_change_radio_structure.php
Last active Nov 3, 2016
Change the structure of Gravity Forms radio fields so it doesn't use the extra ul and li's
View rw_change_radio_structure.php
add_filter( 'gform_field_input', 'rw_change_radio_structure', 10, 5 );
function rw_change_radio_structure($input, $field, $value, $lead_id, $form_id){
$input_type = RGFormsModel::get_input_type($field);
if($input_type != "radio" || IS_ADMIN && RG_CURRENT_VIEW == "entry")
return $input;
$choices = "";
if(is_array($field["choices"])){
$choice_id = 0;
@richardW8k
richardW8k / validate_uk_phone.php
Last active Mar 31, 2016
add to theme functions.php file to add uk as an available format on the phone type field and validation of uk style numbers, pattern from: http://www.coffeecup.com/help/articles/regular-expression-examples/#phonenumber-uk
View validate_uk_phone.php
<?php
//checks to see if a string is a valid UK phone number
add_filter( 'gform_field_validation', 'validate_phone', 10, 4 );
function validate_phone( $result, $value, $form, $field ) {
$pattern = "/^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$/";
if ( $field->type == 'phone' && $this->phoneFormat != 'standard' && ! preg_match( $pattern, $value ) ) {
$result['is_valid'] = false;
$result['message'] = 'Please enter a valid phone number';
}
@richardW8k
richardW8k / radio_input_inside_label.php
Last active Mar 4, 2017
move a Gravity Forms radio input inside the label
View radio_input_inside_label.php
<?php
// move radio input inside label
add_filter("gform_field_choices", "radio_input_inside_label", 10, 2);
function radio_input_inside_label($choices, $field){
if($field["type"] != "radio")
return $choices;
$choices = "";
You can’t perform that action at this time.