@sjaure
many thanks for the code snippet. That’s very helpful.
May I ask one more question.
How do I change the default google map api key without editing plugin code?
I’d like subsites to inherit one key without users having to deal with setting. If there is a constant to define, that would be ideal.
I have come up with the following code, but it doesn’t work somehow.
add_filter( 'tribe_field_value', 'bv_populate_field_with_default_api_key' , 8, 2 );
function bv_populate_field_with_default_api_key( $value_string, $field_name ) {
if ( ! isset( $field_name ) || 'google_maps_js_api_key' !== $field_name ) {
return $value_string;
}
if ( ($value_string == "AIzaSyDNsicAsP6-VuGtAb1O9riI3oc_NOb7IOU" || empty( $value_string )) && function_exists('tribe_update_option') ) {
remove_filter( 'tribe_field_value', array( $this, 'bv_populate_field_with_default_api_key' ), 8, 2 );
$value_string = GOOG_MAP_KEY;
tribe_update_option( 'google_maps_js_api_key', GOOG_MAP_KEY );
add_filter( 'tribe_field_value', array( $this, 'bv_populate_field_with_default_api_key' ), 8, 2 );
}