Support » Plugin: Contact Us Page - Contact People » Fix for incorrect ‘google API invalid’ error following API domain restriction

  • Hi,

    Handy plugin, however there is an issue with the is_valid_google_api_key() function in the contact pages contact people plugin, which needs to add an http referer in the header of the wp_remote_get() request so that the new Google API restrictions don’t return an error code (if this restriction has been set for the API key).


    Replace line 433,

    'timeout'   => 45


    'timeout'   => 45,
    'headers' => array( 'referer' => get_site_url() ) 

    That seems to fix the issue.



Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Steve Truman



    Thanks Will – If you’d like to create a pull request for that we will test it and merge it if ok.



    Hi Steve, just submitted the pull request.

    I also noticed that the validation for the keys in admin settings uses the google fonts api for the validation test, but this may be different from the maps api key, or not used at all. Not a problem to solve by adding the fonts api into the allowed apis for the key in question, but the ‘invalid api key’ error could be confusing for users (I know it confused me initially!;)



    I seem to be having this issue which states
    “This page can’t load Google Maps correctly.
    Do you own this website?”
    I know I have a valid API key cause it used on other apps.

    I have made the change you displayed above but that didn’t seem to help any.

    Also the map doesn’t display at front end and changed the GDPR message at the bottom of the form but it also hasn’t changed at the front end.

    Can you help please.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fix for incorrect ‘google API invalid’ error following API domain restriction’ is closed to new replies.