How can I create a simple RSVP form on my WordPress website?
In the modern digital era, using some kind of online RSVP for an event is more and more common. It allows you to have a singular source for all of the information and can even calculate specific elements or elective items for data to be used later. In the case for me, as a web developer, I decided to create my own wedding website with WordPress. One challenge that I had to attack was creating an online RSVP form that would allow our guests to select from a few simple options and then inform me of their choices.
What plugins do I need?
As a developer I like to attempt to build things custom as much as I can so that I have control of what is happening, but there are plenty of amazing plugins out there that address some major components for you so there is no need to customize everything. For this RSVP project I am using the following WordPress plugins:
- Advanced Custom Fields PRO by Elliot Condon
- Custom Post Type UI by WebDevStudios
- Formidable Forms PRO by Strategy11
Create the RSVP form
- GO to Formidable on the main WordPress dashboard menu..may be labeled Forms
- Create a new form by clicking Add New
- Drag and drop the fields that you need to create your form
- If the form will be public for anyone to view but you want only specific people to submit the form you can use a basic text field as a password field. This way only those that have said password will be able to submit the RSVP form. Unfortunately Formidable requires a function to be added to the functions.php file in order for the password field to work as required.
add_filter('frm_validate_field_entry', 'my_custom_validation', 10, 3);
function my_custom_validation($errors, $posted_field, $posted_value){
if($posted_field->id == 85){ // Change this # to the ID of the field to validate
if(!in_array($posted_value, array('passwordgoeshere'))){ // Change passwordgoeshere to whatever your password will be
$errors['field'. $posted_field->id] = 'That field is wrong!'; // This is your error message
}
}
return $errors;
}
Create a Post Type
- Go to CPT UI in the main WordPress menu
- Create a new post type call RSVP, then click Add Post Type
Create Custom Fields
- Go to Custom Fields on the main WordPress menu
- Click Add New
- Create new custom fields based on any RSVP form fields that you want to gather
- Allocate these new custom fields to your RSVP post type template
Mapping your RSVP form to your new RSVP post type custom fields
- Go to your newly created RSVP form
- Go to Settings > Form Actions for your form
- Click Create Post and make sure that the post type is set you the RSVP post type that you created
- Map any of your form fields with any associated newly created custom fields
Gather the Data
Now that you have an RSVP form, custom fields mapped from your form, and a post type that is gathering that form data, we can now start to show the data either publicly or privately. The following is what I did to easily see the data gathered by the form submissions...
- Created a custom php template in my custom theme
- On my custom RSVP template I added a WP query to list all of the RSVP post type posts, almost like a blog listing page
- Instead of a fancy display of the posts, I created a table that had the following 5 columns (#, Name, Salad, Entre, Email) to match the primary data I wanted to know per submission
- I have the custom fields for columns 2 – 5 displaying and then created a php variable to count the number of submissions for column 1
Extra Credit
So all of the above are the basics that I used to create a cool and usable RSVP form in WordPress in order to make sure that I know who is coming to my event and what options they selected. The following are some other above and beyond things that might be a nice fancy touch to add to the RSVP...
- Guest Confirmation: In Forms > Your RSVP Form > Settings > Form Actions you can create an email notification that goes to the person submitting the form by using an email field mapped to the 'TO' field. This allows you to send a confirmation message to the guest
- Calculating Options: On your custom template you could create a simple table that calculates how many of a particular options your guests are selecting. For instance if you have 2 salad choices, you could calculate based on the guests responses how many of each salad were selected. The same can be said for entrees or other options that are available.