This filter modifies the end result coming from our API. It is an alias of cf_geoplugin_api_response, but with one important distinction — this filter is executed during the final rendering of geolocation data within the plugin.
By using this filter, you are changing the actual data that will be printed on the frontend or returned through shortcodes and widgets.
Note: Modifying this filter affects the functionality of the entire plugin. Use with caution.
Usage
function example_callback( $api_response, $default_api_fields = array() ) {
// Optionally modify $api_response here
return $api_response;
}
add_filter( 'cf_geoplugin_api_render_response', 'example_callback', 1, 2 );
Example
If you want to override the country name with a localized version, use the following snippet:
if ( !function_exists('change_cf_geoplugin_translations') ) {
function change_cf_geoplugin_translations( $response ) {
// Country translation by ISO country code
switch ( $response['country_code'] ) {
case 'FR':
$response['country'] = 'Français';
break;
case 'RS':
$response['country'] = 'Srbija';
break;
case 'CN':
$response['country'] = '中國';
break;
}
// Additional custom modifications can go here
return $response;
}
}
add_filter( 'cf_geoplugin_api_render_response', 'change_cf_geoplugin_translations', 1 );
