Created
June 5, 2023 12:36
-
-
Save geekontheroad/d75f68966fbb4ef675c31afce8b00413 to your computer and use it in GitHub Desktop.
Use gravity forms to create a new attendee for a RSVP list in addEvent.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* simple function that will create a new attendee to an Event in addEvent | |
* | |
* Works with gravity forms by hooking into the gform_after_submission | |
***/ | |
function gotr_create_attendee($entry, $form) { | |
$url = "https://www.addevent.com/api/v1/oe/rsvps/attendee/create/"; | |
$token = "XX_YOUR_TOKEN_HERE_XX"; //AddEvent Token | |
$eventId = "XX_EVENT_ID_HERE_XX"; //The event Id in AddEvent | |
//define forms variables here | |
$name = rgar($entry, "13.3") . " " . rgar($entry, "13.6"); | |
$email = rgar($entry, "6"); | |
$attending = rgar($entry, "16"); //1(going) 2(maybe) 3(not going) | |
//https://www.addevent.com/c/documentation/events-api | |
$postData = array( | |
"token" => $token, | |
"event_id" => $eventId, | |
"name" => $name, | |
"email" => $email, | |
"attending" => $attending, | |
"notify" => "active", | |
); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($ch); | |
if (curl_errno($response)) { | |
$error_msg = curl_error($ch); | |
} | |
curl_close($ch); | |
if (isset($error_msg)) { | |
GFCommon::log_debug(__METHOD__ . " Curl error during adding attendee " . $error_msg); | |
} else { | |
GFCommon::log_debug(__METHOD__ . " Attendee created " . $response); | |
} | |
} | |
add_action("gform_after_submission_27", "gotr_create_attendee", 10,2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment