A backend event that fires when a Guest is created.
The onGuestCreated()
event handler runs when a Guest is created on your site. The received GuestCreated
object contains information about the new guest.
Note: Backend events are not fired when previewing your site.
function wixEventsGuests_onGuestCreated(event: GuestCreated): void;
Information about the created guest and onGuestCreated
event.
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixEventsGuests_onGuestCreated(event) {
const eventId = event.metadata.id;
const entityId = event.entity._id;
}
/* Full guest object:
{
"metadata": {
"id": "02459af3-da70-4173-a607-65678e99ef30",
"entityId": "afda7995-72d0-4d58-9ba4-3f6c5213c35c",
"eventTime": "2023-04-19T12:39:05.690213Z",
"triggeredByAnonymizeRequest": false
},
"entity": {
"_id": "afda7995-72d0-4d58-9ba4-3f6c5213c35c",
"eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192",
"orderNumber": "2TFG-RXPW-00Z",
"tickets": [
{
"number": "2TFG-RXPW-00Z1P",
"definitionId": "9b5b5cc0-b017-49d1-a59c-81c7cff580a6",
"name": "Participant Ticket"
}
],
"contactId": "023b6403-17e6-42dc-b475-a5ae6c2b8df4",
"guestDetails": {
"email": "john.doe@mail.com",
"firstName": "John",
"lastName": "Doe",
"formResponse": {
"inputValues": [
{
"inputName": "firstName",
"value": "John",
"values": []
},
{
"inputName": "lastName",
"value": "Doe",
"values": []
},
{
"inputName": "email",
"value": "john.doe@mail.com",
"values": []
}
]
},
"checkedIn": false
},
"attendanceStatus": "ATTENDING",
"_createdDate": "2023-04-19T12:39:05.561Z",
"_updatedDate": "2023-04-19T12:39:05.602Z",
"attendanceStatusUpdatedDate": "2023-04-19T12:39:05.424Z",
"guestType": "BUYER"
}
}
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.