Skip to content

Instantly share code, notes, and snippets.

@geekontheroad
Created June 5, 2023 12:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Use gravity forms to create a new attendee for a RSVP list in addEvent.com
<?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