Kjapp og trygg hosting for Wordpress

WP Gravity forms til Zendesk

Tonny Kluften

Administrator
Jeg skal lage et kontaktskjema i Wordpress med Gravity Forms som automatisk poster tickets i Zendesk, Men får error.

Fatal error: Call to undefined function ZD_contactus_curlWrap() in/home/webforum/public_html/webhotell/wp-content/themes/aquamag-child/functions.phpon line49

Her er koden som limes inn i function.php:
Kode:
/*
* ZENDESK API
*/
define("ZDAPIKEY", "wEfhLXe7h81qhahahahahahandQRuSZ3g71DzN3ACOw");
define("ZDUSER", "post@lykkemedia.no");
define("ZDURL", "https://lykkemedia.zendesk.com/api/v2");
/*
* Here goes the Gravity Forms Functions
*/
add_action("gform_after_submission_1", "send_contact_to_zendesk", 10, 2); // Invoke ZENDESK for form #1
add_action("gform_after_submission_1", "ult_cu_disable_post_creation", 20, 2); // Disable entry creation for FROM id #1
/*
* Deletes entry created in WordPress Dashboard
*/
function ult_cu_disable_post_creation( $entry, $form ) {
GFAPI::delete_entry( $entry['id'] );
}
/*
* Prepares and sends data to Zendesk
*/
function send_contact_to_zendesk($entry,$form){
$create = json_encode(
array(
'ticket' => array(
'subject' => $entry[1]. '-' .$entry[8], // Title of ticket ids of fields you need in subject field ours was type of request - message title
'comment' => array(
"value"=> $entry[2] // content of the ticket
),
'requester' => array(
'name' => $entry[3], // Name of ticket creator
'email' => $entry[5] // email of ticket creator
)
)
)
);
$return = ZD_contactus_curlWrap("/tickets.json", $create);
}
/*
* Zendesk post function
* TODO : use wp_remote_post
*/
function ZD_contact_us_curlWrap($url, $json){
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt($ch, CURLOPT_URL, ZDURL.$url);
curl_setopt($ch, CURLOPT_USERPWD, ZDUSER."/token:".ZDAPIKEY);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
$decoded = json_decode($output);
return $decoded;
}
 

spikre

peterhamre.no
Helt enkelt sier meldingen at funksjonen ZD_contactus_curlWrap ikke er definert. Hvor denne er test at skal defineres vet jeg ikke, men det er antagelig i en annen fil, eller noe du har glemt å lime inn fra modulen du har brukt som utgangspunkt.

Altså; du sier
PHP:
$return = ZD_contactus_curlWrap("/tickets.json", $create);
Men hva skal ZD_contactus_curlWrap gjør med de to parameterne?
 
Topp