automator_getresponse_custom_field_value
Filter the error value. Filters the GetResponse custom field value before it's saved.
add_filter( 'automator_getresponse_custom_field_value', $callback, 10, 2 );
Description
Fires when retrieving a GetResponse custom field value. Developers can modify the field value, the field ID, or the field configuration before it's used to add or update a contact. This allows for custom data manipulation or error handling specific to GetResponse integrations.
Usage
add_filter( 'automator_getresponse_custom_field_value', 'your_function_name', 10, 2 );
Parameters
-
$error(WP_Error) - - **$field_id** `string`
-
$value(mixed) - - **$field_config** `array`
Return Value
WP_Error
Examples
<?php
/**
* Example: Modify the value of a specific GetResponse custom field before it's saved.
* This example assumes you have a custom field in GetResponse with the ID 'user_city'
* and you want to ensure it's always capitalized.
*/
add_filter( 'automator_getresponse_custom_field_value', function( $error, $field_id, $value, $field_config ) {
// Check if this filter is for the 'user_city' custom field.
if ( $field_id === 'user_city' && ! is_wp_error( $error ) ) {
// Ensure the value is a string before attempting to capitalize.
if ( is_string( $value ) ) {
// Capitalize the first letter of the city and return the modified value.
return ucwords( $value );
} else {
// If the value isn't a string, return an error indicating an invalid type.
return new WP_Error( 'invalid_field_type', __( 'The value for the city field must be a string.', 'your-text-domain' ) );
}
}
// If it's not the 'user_city' field or if there was already an error, pass through the original value/error.
return $error;
}, 10, 4 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/integrations/get-response/actions/gr-add-update-contact.php:438
src/integrations/get-response/actions/gr-add-update-contact.php:454
src/integrations/get-response/actions/gr-add-update-contact.php:508
src/integrations/get-response/actions/gr-add-update-contact.php:529
* return // non WP_Error value to validate.
* }
* return $error;
* }, 10, 4 );
*
* @return WP_Error
*/
$value = apply_filters( 'automator_getresponse_custom_field_value', $error, $field_id, $value, $field_config );
if ( is_wp_error( $value ) ) {
return $value;
}
}
/**
* Filter the validated value.
Internal Usage
Found in src/integrations/get-response/actions/gr-add-update-contact.php:429:
* add_filter( 'automator_getresponse_custom_field_value', function( $error, $field_id, $value, $field_config ) {
Found in src/integrations/get-response/actions/gr-add-update-contact.php:525:
* add_filter( 'automator_getresponse_custom_field_value', function( $validated, $field_id, $value, $field_config ) {