add_action( 'gform_after_submission_1', 'process_ticket_application', 10, 3 );
function process_ticket_application( $entry, $form ) {
$email = $entry['your_field_id'];
$firstname = $entry['your_field_id'];
$lastname = $entry['your_field_id'];
$page_title = $entry['your_field_id'];
$company = $entry['your_field_id'];
$ticket_id = $entry['your_field_id'];
$hopin_api_ticket_url = "https://api.hopin.com/v1/tickets/";
$url = $hopin_api_ticket_url . $ticket_id . "/magicLinks";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Accept: application/json",
"Authorization: Bearer YOUR_HOPIN_KEY",
"Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$timestamp = time();
$unique_reg_id = md5($email . $timestamp);
$send = array(
"data" => array(
"type" => "magicLink",
"attributes" => array(
"email" => $email,
"firstName" => $firstname,
"headline" => $company,
"lastName" => $lastname,
"registrationId" => $unique_reg_id
)
)
);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($send));
$resp = curl_exec($curl);
curl_close($curl);
$response = json_decode($resp);
$magicLink = $response->data->attributes->magicLink;
//From here you can do something else like send the user a custom email with the magic link
}