Hello, I am using the gform_after_submission action to post submission data to an external database. When Japanese or other international users submit form fields the data shows with missing characters. Weirdly, I can see the characters fine in the “Entries” section of gravity forms. And the database accepts unicode characters. I believe these characters are being stripped when I use the rgar function to assign the values to the $data array: ‘first_name’ => rgar( $entry, ‘14’ ).
Here is the function:
function post_to_mydatabase( $entry, $form ) {
function post_to_url($url, $data) {
$fields = '';
foreach($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, count($data));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
// I tried adding this below with no luck...
//curl_setopt($post, CURLOPT_HTTPHEADER, array ('Content-Type: text/html, charset=utf-8'));
$result = curl_exec($post);
curl_close($post);
}
//Brochure Request
if($form["id"] == 1){
$data = array(
'first_name' => rgar( $entry, '1' ),
'last_name' => rgar( $entry, '2' ),
'company' => rgar( $entry, '3' ),
'address' => rgar( $entry, '4.1' ),
'city' => rgar( $entry, '4.3' ),
'provinces_states' => rgar( $entry, '4.4' ),
'zip' => rgar( $entry, '4.5' ),
'country' => rgar( $entry, '4.6' ),
'phone' => rgar( $entry, '5' ),
'email_address' => rgar( $entry, '6' ),
);
post_to_url("https://mydatabase.com/external_requesthandler.lf", $data);
}
}
Does anyone have a workaround or am I missing something?