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
| Parameter | Type | Description |
|---|---|---|
$formatted_with_country_code | string | The default output of the phone field with country code. |
$value | string | The original field value. |
$entry | Entry Object | The current entry. |
$use_text | boolean | Whether to use the text format. |
$format | string | The format requested for the location the merge tag is being used. |
$field | Field Object | The 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.