This filter modifies the final API response returned by the Geo Controller plugin.
Note: Modifying this filter impacts the core behavior of the plugin globally. 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_response', 'example_callback', 1, 2 );
Example
If you want to translate the country name based on your local preferences, you can do so by checking the country_code
value and modifying the response accordingly:
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 customizations can be added here return $response; } } add_filter( 'cf_geoplugin_api_response', 'change_cf_geoplugin_translations', 1 );