gform_admin_notification_attachments

gform_admin_notification_attachments

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter can be used to add attachments to the admin notification email.

This hook has been deprecated in v. 1.7. Please use gform_notification instead.

Usage
1add_filter( 'gform_admin_notification_attachments', 'add_attachment', 10, 3 );
You can also target a specific form by adding the form id after the hook name.
12//This filter declaration targets a form whose id is 6add_filter( 'gform_admin_notification_attachments_6', 'add_attachment', 10, 3 );

Parameters

$attachments string, array
The attachments to be filtered. It can be a simple strings containing for file path for one attachments or an array of strings for multiple attachments.

$entry Entry Object
Current entry object.

$form Form Object
Current form object.

Examples
This example attaches all file upload fields in the form to the admin notification email.
1234567891011121314151617add_filter( 'gform_admin_notification_attachments_4', 'add_attachment', 10, 3 );function add_attachment( $attachments, $lead, $form ) {    $fileupload_fields = GFCommon::get_fields_by_type( $form, array( 'fileupload' ) );    if ( ! is_array( $fileupload_fields ) ) {        return $attachments;    }    $attachments = array();    $upload_root = RGFormsModel::get_upload_root();    foreach ( $fileupload_fields as $field ) {        $url = $lead[ $field['id'] ];        $attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $url );        if ( $attachment ) {            $attachments[] = $attachment;        }    }    return $attachments;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in common.php

gform_admin_messages

gform_admin_messages

DescriptionUsageParametersExamplesPlacementSource Code

Description
Modify update (and other non-error) messages displayed by Gravity Forms in the WordPress admin.
Usage
1add_action( 'gform_admin_messages', 'my_custom_function' );
Parameters

$messages array
An array of messages to be displayed below the title on Gravity Form pages.

Examples
This example demonstrates how we can append a 『Preview Form』 link to any update message where a form ID is available in the query string.
123456789101112131415161718add_action( 'gform_admin_messages', 'my_append_preview_form_link' );function my_append_preview_form_link( $messages ) {     // get the form ID from the query string    $form_id = rgget( 'id' );     // if no form ID is available, let's not add the 'Preview Form' link    if ( ! $form_id ) {        return;    }     // loop through our error messages and append the 'Preview Form' link    foreach ( $messages as &$message ) {        $message .= ' Preview Form';    }     return $messages;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::display_admin_message() in common.php

gform_admin_error_messages

gform_admin_error_messages

DescriptionUsageParametersExamplesSource Code

Description
Modify error messages displayed by Gravity Forms in the WordPress admin.
Usage
1add_action( 'gform_admin_error_messages', 'my_custom_function' );
Parameters

$error_messages array
An array of error messages to be displayed below the title on Gravity Form pages.

Examples
This example demonstrates how we can remove an error message.
123456789101112131415add_action( 'gform_admin_error_messages', 'my_remove_error_message' );function my_remove_error_message( $errors ) {     // loop through our error messages    for ( $i = count( $errors ); $i > 0; $i-- ) {         // check if this is the error message we want to remove        if ( $errors[$i] == __( 'Please select the fields to be exported', 'gravityforms' ) ) {            unset( $errors[$i] );        }     }     return $errors;}
Source Code
This filter is located in GFCommon::display_admin_message() in common.php

gform_address_zip

gform_address_zip

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address zip field and can be used to modify the 「Zip」 label.
Usage
Applies to all forms
1add_filter( 'gform_address_zip', 'change_address_zip', 10, 2 );
Applies to a specific form. In this case, form Id 5
1add_filter( 'gform_address_zip_5', 'change_address_zip', 10, 2 );
Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default address zip label:
1234add_filter( 'gform_address_zip', 'change_address_zip', 10, 2 );function change_address_zip( $label, $form_id ) {    return "Address Zip";}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in js.php and GF_Field_Address::get_field_input() in includes/fields/class-gf-field-address.php.

gform_address_types

gform_address_types

DescriptionUsageParametersExamples1. Brasil2. Australia3. United KingdomPlacementSinceSource Code

Description
This filter is executed when creating the address field (admin and front end). Use it to add support for a new address type.
Usage
The following would apply to all forms:
1add_filter( 'gform_address_types', 'brazilian_address', 10, 2 );
To target a specific form, append the form id to the hook name. (format: gform_address_types_FORMID)
1add_filter( 'gform_address_types_5', 'brazilian_address', 10, 2 );

Parameters

$address_types array
A list of all configured address types to be filtered. Following is the default declaration of this array.
123456789101112131415161718192021$addressTypes = array(        'international' => array(            'label'       => 'International',            'zip_label'   => 'Zip / Postal Code',            'state_label' => 'State/Province/Region'        ),        'us'            => array(            'label'       => 'United States',            'zip_label'   => 'Zip Code',            'state_label' => 'State',            'country'     => 'United States',            'states'      => GF_Fields::get( 'address' )->get_us_states(),        ),        'canadian'      => array(            'label'       => 'Canadian',            'zip_label'   => 'Postal Code',            'state_label' => 'Province',            'country'     => 'Canada',            'states'      => GF_Fields::get( 'address' )->get_canadian_provinces()        )    );

$form_id integer
The current form ID.

Examples
1. Brasil
This example adds a Brazilian address type to the list.
123456789101112131415add_filter( 'gform_address_types', 'brazilian_address', 10, 2 );function brazilian_address( $address_types, $form_id ) {    $address_types['brazil'] = array(        'label'       => 'Brasil',        'country'     => 'Brasil',        'zip_label'   => 'CEP',        'state_label' => 'Estado',        'states'      => array(            '', 'Acre', 'Alagoas', 'Amapa', 'Amazonas', 'Bahia', 'Ceara', 'Distrito Federal', 'Espirito Santo', 'Goias', 'Maranhao', 'Mato Grosso', 'Mato Grosso do Sul', 'Minas Gerais',            'Para', 'Paraiba', 'Parana', 'Pernambuco', 'Piaui', 'Roraima', 'Rondonia', 'Rio de Janeiro', 'Rio Grande do Norte', 'Rio Grande do Sul', 'Santa Catarina', 'Sao Paulo', 'Sergipe', 'Tocantins'        )    );     return $address_types;}
2. Australia
This example adds an Australian address type.
123456789101112131415161718192021add_filter( 'gform_address_types', 'australian_address_type' );function australian_address_type( $address_types ) {    $address_types['australia'] = array(        'label'       => 'Australian',        'country'     => 'Australia',        'zip_label'   => 'Postcode',        'state_label' => 'State',        'states'      => array(            'ACT' => 'Australian Capital Territory',            'NT'  => 'Northern Territory',            'NSW' => 'New South Wales',            'QLD' => 'Queensland',            'SA'  => 'South Australia',            'TAS' => 'Tasmania',            'VIC' => 'Victoria',            'WA'  => 'Western Australia',        )    );     return $address_types;}
3. United Kingdom
This example uses optgroups for the counties, a feature added in Gravity Forms 2.0-beta-2.2.
1234567891011121314151617181920212223242526add_filter( 'gform_address_types', 'uk_address', 10, 2 );function uk_address( $address_types, $form_id ) {    $address_types['uk'] = array(        'label'       => 'UK',        'country'     => 'United Kingdom',        'zip_label'   => 'Postcode',        'state_label' => 'County',        'states'      => array(            '',            'England'          => array(                'Avon', 'Bedfordshire', 'Berkshire', 'Buckinghamshire', 'Cambridgeshire', 'Cheshire', 'Cleveland', 'Cornwall', 'Cumbria', 'Derbyshire', 'Devon', 'Dorset', 'Durham', 'East Sussex', 'Essex', 'Gloucestershire', 'Hampshire', 'Herefordshire', 'Hertfordshire', 'Isle of Wight', 'Kent', 'Lancashire', 'Leicestershire', 'Lincolnshire', 'London', 'Merseyside', 'Middlesex', 'Norfolk', 'Northamptonshire', 'Northumberland', 'North Humberside', 'North Yorkshire', 'Nottinghamshire', 'Oxfordshire', 'Rutland', 'Shropshire', 'Somerset', 'South Humberside', 'South Yorkshire', 'Staffordshire', 'Suffolk', 'Surrey', 'Tyne and Wear', 'Warwickshire', 'West Midlands', 'West Sussex', 'West Yorkshire', 'Wiltshire', 'Worcestershire',            ),            'Wales'            => array(                'Clwyd', 'Dyfed', 'Gwent', 'Gwynedd', 'Mid Glamorgan', 'Powys', 'South Glamorgan', 'West Glamorgan',            ),            'Scotland'         => array(                'Aberdeenshire', 'Angus', 'Argyll', 'Ayrshire', 'Banffshire', 'Berwickshire', 'Bute', 'Caithness', 'Clackmannanshire', 'Dumfriesshire', 'Dunbartonshire', 'East Lothian', 'Fife', 'Inverness-shire', 'Kincardineshire', 'Kinross-shire', 'Kirkcudbrightshire', 'Lanarkshire', 'Midlothian', 'Moray', 'Nairnshire', 'Orkney', 'Peeblesshire', 'Perthshire', 'Renfrewshire', 'Ross-shire', 'Roxburghshire', 'Selkirkshire', 'Shetland', 'Stirlingshire', 'Sutherland', 'West Lothian', 'Wigtownshire',            ),            'Northern Ireland' => array(                'Antrim', 'Armagh', 'Down', 'Fermanagh', 'Londonderry', 'Tyrone',            ),        ),    );     return $address_types;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 1.4.
Source Code
This action hook is located in GF_Field_Address::get_address_types() in includes/fields/class-gf-field-address.php.

gform_address_street2

gform_address_street2

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address street 2 field and can be used to modify the 「Street 2」 label.
Usage
Applies to all forms.
1add_filter( 'gform_address_street2', 'change_address_street2', 10, 2 );
Applies to a specific form. In this case, form id 5.
1add_filter( 'gform_address_street2_5', 'change_address_street2', 10, 2 );
Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default address street 2 label:
1234add_filter( 'gform_address_street2', 'change_address_street2', 10, 2 );function change_address_street2( $label, $form_id ) {    return "Address Street 2";}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in js.php and GF_Field_Address::get_field_input() in includes/fields/class-gf-field-address.php.

gform_address_street

gform_address_street

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address street field and can be used to modify the 「Street」 label.
Usage
Applies to all forms.
add_filter( 'gform_address_street', 'change_address_street', 10, 2 );

Applies to a specific form. In this case, form id 5.
add_filter( 'gform_address_street_5', 'change_address_street', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default address street label:
add_filter( 'gform_address_street', 'change_address_street', 10, 2 );
function change_address_street( $label, $form_id ) {
return "Address Street";
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in js.php and GF_Field_Address::get_field_input() in includes/fields/class-gf-field-address.php.

gform_address_state

gform_address_state

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address state field and can be used to modify the 「State」 label.
Usage
Applies to all forms.
add_filter( 'gform_address_state', 'change_address_state', 10, 2 );

Applies to a specific form. In this case, form id 5.
add_filter( 'gform_address_state_5', 'change_address_state', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default address state label:
add_filter( 'gform_address_state', 'change_address_state', 10, 2 );
function change_address_state( $label, $form_id ) {
return "Address State";
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in js.php and GF_Field_Address::get_field_input() in includes/fields/class-gf-field-address.php.

gform_address_display_format

gform_address_display_format

DescriptionUsageParametersExamplesSinceSource Code

Description
This filter can be used to change the way addresses are formatted.
Usage
add_filter( 'gform_address_display_format', 'change_address', 10, 2 );

Parameters

$format string
The format to be filtered.
Possible values: default and zip_before_city.

default
Addresses are formatted in the following order: Street, Street2, City, State, Zip Code, Country.

zip_before_city
Addresses are formatted in the following order: Street, Street2, Zip, City, State, Country.

$field Field Object
The current field.

Examples
This example demonstrates how to change the address format to zip_before_city.
add_filter( 'gform_address_display_format', 'address_format', 10, 2 );
function address_format( $format, $field ) {
return 'zip_before_city';
}

Since
This filter was added in Gravity Forms version 1.5.28.
Added $field parameter in 1.9.2.
Source Code
This filter is located in the following methods in includes/fields/class-gf-field-address.php:

GF_Field_Address::get_field_input()
GF_Field_Address::get_value_entry_detail()

gform_address_country

gform_address_country

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address country field and can be used to modify the 「Country」 label.
Usage
Applies to all forms.
1add_filter( 'gform_address_country', 'change_address_country', 10, 2 );
Applies to a specific form. In this case, form id 5.
1add_filter( 'gform_address_country_5', 'change_address_country', 10, 2 );
Parameters

$label string
The label to be filtered.

$form_id
The current form』s id.

Examples
This example changes the default address country label:
1234add_filter( 'gform_address_country', 'change_address_country', 10, 2 );function change_address_country( $label, $form_id ) {    return "Address Country";}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in js.php and GF_Field_Address::get_field_input() in includes/fields/class-gf-field-address.php.