The gform_cleverreach_field_value Gravity Forms PHP function allows you to modify the value of a field before it’s sent to the CleverReach API.
Usage
add_filter( 'gform_cleverreach_field_value', 'customize_cleverreach_field_value', 10, 4 ); function customize_cleverreach_field_value( $field_value, $field, $entry, $form ) { // Your custom code here return $field_value; }
Parameters
$field_value
(mixed): The current value of the field.$field
(GF_Field): The field object.$entry
(array): The entry data.$form
(array): The form data.
More information
See Gravity Forms Docs: gform_cleverreach_field_value
Examples
Change the value of a specific field
Change the value of a specific field before it’s sent to CleverReach.
add_filter( 'gform_cleverreach_field_value', 'change_specific_field_value', 10, 4 ); function change_specific_field_value( $field_value, $field, $entry, $form ) { if ( $field->id == 3 ) { $field_value = 'New Value'; } return $field_value; }
Add a prefix to all field values
Add a prefix to all field values before sending them to CleverReach.
add_filter( 'gform_cleverreach_field_value', 'add_prefix_to_field_values', 10, 4 ); function add_prefix_to_field_values( $field_value, $field, $entry, $form ) { $field_value = 'Prefix_' . $field_value; return $field_value; }
Format phone numbers
Format phone numbers before sending them to CleverReach.
add_filter( 'gform_cleverreach_field_value', 'format_phone_numbers', 10, 4 ); function format_phone_numbers( $field_value, $field, $entry, $form ) { if ( $field->type == 'phone' ) { $field_value = preg_replace( '/[^0-9]/', '', $field_value ); } return $field_value; }
Convert text to uppercase
Convert text to uppercase before sending to CleverReach.
add_filter( 'gform_cleverreach_field_value', 'convert_text_to_uppercase', 10, 4 ); function convert_text_to_uppercase( $field_value, $field, $entry, $form ) { if ( $field->type == 'text' ) { $field_value = strtoupper( $field_value ); } return $field_value; }
Replace empty field values
Replace empty field values with a default value before sending to CleverReach.
add_filter( 'gform_cleverreach_field_value', 'replace_empty_field_values', 10, 4 ); function replace_empty_field_values( $field_value, $field, $entry, $form ) { if ( empty( $field_value ) ) { $field_value = 'N/A'; } return $field_value; }