oomphinc / gravity-forms-google-places

Adds a location field type that integrates with the Google Places API.
13 stars 15 forks source link

Add option to enter API key #1

Open balbuf opened 8 years ago

balbuf commented 8 years ago

API key is currently optional to use the Places API, but some users may wish to use theirs.

faridjame commented 7 years ago

Can you tell me where the API key needs to be added in the code?

cameronjonesweb commented 6 years ago

Add this code to your theme or a custom plugin to add an API key

add_filter( 'script_loader_src', 'gfgp_api_key', 10, 2 );
function gfgp_api_key( $src, $handle ) {
    if( 'google-places' === $handle ) {
        $src = add_query_arg( array(
            'key' => 'your_key_here'
        ), $src );
    }
    return $src;
}
mattyjneal commented 5 years ago

Worked for me, Thanks!

paolodagostino commented 4 years ago

add_filter( 'script_loader_src', 'gfgp_api_key', 10, 2 ); function gfgp_api_key( $src, $handle ) { if( 'google-places' === $handle ) { $src = add_query_arg( array( 'key' => 'your_key_here' ), $src ); } return $src; }

I am not sure on where to put this code.

Is there any setup configuration in the plugin?

dexit commented 4 years ago

add_filter( 'script_loader_src', 'gfgp_api_key', 10, 2 ); function gfgp_api_key( $src, $handle ) { if( 'google-places' === $handle ) { $src = add_query_arg( array( 'key' => 'your_key_here' ), $src ); } return $src; }

I am not sure on where to put this code.

Is there any setup configuration in the plugin?

your themes functions.php file