I try to translate address entries in pre submission

function translate_entries( $form ) {

	$apiKey = '';
	$text = $_POST['input_24_6'];
	$url = 'https://www.googleapis.com/language/translate/v2?key=' . $apiKey . '&q=' . rawurlencode($text) . '&target=en';

	$handle = curl_init($url);
	curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
	$response = curl_exec($handle);
	$responseDecoded = json_decode($response, true);
	$responseCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);      //Here we fetch the HTTP response code

	if($responseCode != 200) {
		$_POST['input_24_6'] = $responseDecoded['error']['errors'][0]['message'];
	else {
		$_POST['input_24_6'] = $responseDecoded['data']['translations'][0]['translatedText'];


my question is for the address the variable is _POST ['input_24_6'] is it correct? or should it be so? _POST [‘input_24’] [6]

That would never be correct. In order to figure out what the $_POST looks like, I recommend adding this logging line in your function:

GFCommon::log_debug( __METHOD__ . '(): The POST => ' . print_r( $_POST, true ) );

For that to do anything useful, you will need to enable logging first:

Once you test the form, check the Gravity Forms Core log for the phrase “The POST” to check the format of your fields as they appear in the $_POST.

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.