Events Manager, WordPress Multi-Blog Site & Google Maps API Key Fix

July 13th, 2010 | No Comments | Posted in Events Manager, Hacks & Mods, Wordpress

To go along with my last post, here’s another fix for sites with multiple blogs and domain mapping. If you have two or more sites each with a unique domain name, you’ll need two (or more) Google Maps API keys, one for each domain. The reason is that Google ties the keys to the domain name, so www.siteone.com and www.sitetwo.com have to have their own API keys.

No big deal to get two keys and enter the correct one for each blog, but on the backend, you’re always using your primary blog domain — the url looks like www.siteone.com/sitetwo. So the Events Manager plug-in is pulling up the API key for www.sitetwo.com, but Google is registering the request as being from site one and you’ll get an error telling you that the key isn’t valid for this domain.

The solution is to edit the dbem_events.php file where it currently reads:

  1. $gmap_key = get_option('dbem_gmap_key')

Replace that with:  

  1. $gmap_key = get_blog_option ( get_site_option('dashboard_blog'), 'dbem_gmap_key' );

That will use the primary blog’s Google Map API key when you’re in the Dashboard, but you’ll still be using the secondary blog API key from the front end.

Leave a Reply