Client Pay Portal

How to add event attendees using the Kentico CMS API

The Kentico CMS platform is one of the most extendable and usable APIs I’ve ever worked with. There is literally nothing I haven’t been able to do with, assuming it’s programmatically possible. For many projects we have leveraged the API to automate processes, enhance functionality, and create dynamic, feature-rich applications. This blog details using the API to automatically add attendees to an existing Event/Booking event.

1. Make sure there is an event to assign the user to.

The first step in adding an attendee to an event is to make sure there is an event to add them to. The Event attendee is a Kentico-created data structure and requires an Event Node ID. This ID is to the associated TreeNode of the event the user is associated with.  
//instantiate tree provider
UserInfo ui = UserInfoProvider.GetUserInfo(CMSContext.CurrentUser.UserID);
tree = new TreeProvider(ui);
TreeNode node = tree.SelectSingleNode([TreeNode ID]);
if(node != null)
    //Create the event attendee

2. Make sure the attendee isn’t already registered.

Every attendee is unique by their email address and event. An email address can only be associated with one event within the system to make sure notifications / registrations are tracked correctly. Before adding any attendee, make sure the email address isn’t already in use.
//Make sure the attendee isn't already registered for the event
eai = EventAttendeeInfoProvider.GetEventAttendeeInfo(node.NodeID, dr["email"].ToString());
//Check if an attendee is already registered 
if (eai == null)
    //Add the attendee 

3. Create the new attendee

Kentico has a set number of fields pre-created for each attendee. These include first / last name, email address, and phone number. Additional fields can be added and set during the creation process, as shown below. Using the API, you can easily set the values and save the attendee to the system.
eai = new EventAttendeeInfo();
// Set the properties
eai.AttendeeEmail = “”;
eai.AttendeeEventNodeID = Convert.ToInt32(dsEventNode.Tables[0].Rows[0]["NodeID"].ToString());
eai.AttendeeFirstName = "Francis";
eai.AttendeeLastName = "Fratelli";
eai.SetValue("Title""Toupee King"// This is a custom field
eai.SetValue("OrderId", 123); // This is a custom field 
// Save the attendee

The main code above is the “SetAttendeeInfo” method. This actually creates the attendee record and associates it with the specified node id. Hopefully this code will help in automating your event process and assist in creating a dynamic, functional site!


You can check of the Event API in the Kentico Developer guide here.



Wiz E. Wig, Mascot & Director of Magic
Wiz E. Wig

Director of Magic