Sorry... solved the problem several days ago by placing the cURL code on the confirmation page. Yes, the confirmation page is a redirect with a full URL. Here's what I had as the hook:
add_action('gform_after_submission_1', 'post_to_act_on_form', 10, 2);
function post_to_act_on_form($entry, $form) {
if (!function_exists('curl_init')) {
error("Curl is not setup on this PHP server and is required for this script");
}
else {
$row_arr = array();
$row_arr["First Name"] = stripslashes($entry['11.3']);
$row_arr["Last Name"] = stripslashes($entry['11.6']);
$row_arr["E-mail Address"] = stripslashes($entry['12']);
$row_arr["Quiz1"] = stripslashes($entry['13']);
$row_arr["Quiz2"] = stripslashes($entry['14']);
$row_arr["Quiz3"] = stripslashes($entry['15']);
$row_arr["Quiz4"] = stripslashes($entry['16']);
$row_arr["Quiz5"] = stripslashes($entry['17']);
$row_arr["Quiz6"] = stripslashes($entry['18']);
$row_arr["Quiz7"] = stripslashes($entry['19']);
$row_arr["Quiz8"] = stripslashes($entry['20']);
$row_arr["Quiz9"] = stripslashes($entry['21']);
$row_arr["Quiz10"] = stripslashes($entry['22']);
// Post to Act-On form
$ch2 = curl_init();
if (curl_error($ch2) != "") { echo "Error: $error\n";}
// Point to Act-On External Post URL
curl_setopt($ch2, CURLOPT_URL, "http://www.actonsoftware.com/acton/eform/1854/0003/d-ext-0001");
// Set the method to POST
curl_setopt($ch2, CURLOPT_POST, 1);
// Pass POST data
curl_setopt($ch2, CURLOPT_USERAGENT, getenv("HTTP_USER_AGENT"));
curl_setopt($ch2, CURLOPT_POSTFIELDS, http_build_query($row_arr, '', '&'));
curl_exec($ch2);
curl_close($ch2); // close cURL resource
}
}
add_action('gform_after_submission_1', 'post_to_act_on_form', 10, 2);
function post_to_act_on_form($entry, $form) {
if (!function_exists('curl_init')) {
error("Curl is not setup on this PHP server and is required for this script");
}
else {
$row_arr = array();
$row_arr["First Name"] = stripslashes($entry['11.3']);
$row_arr["Last Name"] = stripslashes($entry['11.6']);
$row_arr["E-mail Address"] = stripslashes($entry['12']);
$row_arr["Quiz1"] = stripslashes($entry['13']);
$row_arr["Quiz2"] = stripslashes($entry['14']);
$row_arr["Quiz3"] = stripslashes($entry['15']);
$row_arr["Quiz4"] = stripslashes($entry['16']);
$row_arr["Quiz5"] = stripslashes($entry['17']);
$row_arr["Quiz6"] = stripslashes($entry['18']);
$row_arr["Quiz7"] = stripslashes($entry['19']);
$row_arr["Quiz8"] = stripslashes($entry['20']);
$row_arr["Quiz9"] = stripslashes($entry['21']);
$row_arr["Quiz10"] = stripslashes($entry['22']);
// Post to Act-On form
$ch2 = curl_init();
if (curl_error($ch2) != "") { echo "Error: $error\n";}
// Point to Act-On External Post URL
curl_setopt($ch2, CURLOPT_URL, "http://www.actonsoftware.com/acton/eform/1854/0003/d-ext-0001");
// Set the method to POST
curl_setopt($ch2, CURLOPT_POST, 1);
// Pass POST data
curl_setopt($ch2, CURLOPT_USERAGENT, getenv("HTTP_USER_AGENT"));
curl_setopt($ch2, CURLOPT_POSTFIELDS, http_build_query($row_arr, '', '&'));
curl_exec($ch2);
curl_close($ch2); // close cURL resource
}
Posted 13 years ago on Thursday February 23, 2012 |
Permalink