gform_phone_formatted_all_fields

Description

The gform_phone_formatted_all_fields filter allows developers to filter the value of the phone field when used in the {all_fields} merge tag.

Usage

Applies to all forms.

add_filter( 'gform_phone_formatted_all_fields', 'your_function_name', 10, 6 );

Applies to a specific form. In this case, form id 5.

add_filter( 'gform_phone_formatted_all_fields_5', 'your_function_name', 10, 6 );

Parameters

ParameterTypeDescription
$formatted_with_country_codestringThe default output of the phone field with country code.
$valuestringThe original field value.
$entryEntry ObjectThe current entry.
$use_textbooleanWhether to use the text format.
$formatstringThe format requested for the location the merge tag is being used.
$fieldField ObjectThe phone field object (GF_Field_Phone).

Examples

Change the {all_fields} output for the phone field.

add_filter( 'gform_phone_formatted_all_fields', 'change_all_fields_output', 10, 6 );
function change_all_fields_output( $formatted_with_country_code, $value, $entry, $use_text, $format, $field ) {
	return $field->get_value_entry_detail( $value, '', $use_text, $format, 'email' );
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in includes/fields/class-gf-field-phone.php.

Since

This filter was added in Gravity Forms 3.1.2.