Web Analytics

The Events Calendar: Checking for Multiple Venue Conflicts

by Utsab Karki, Senior WordPress Developer

Photo by Vidal Balielo Jr. via Pexels

The Events Calendar, as you may know, is one of the most popular WordPress plugins for managing events.

We’ve written plenty about it before, showcasing how to update the calendar to the new V2 views, how to hide events in WordPress search results, and how to implement tickets and RSVPs for recurring events.

Most recently, we explained how to check for venue conflicts when adding an event – ensuring you wouldn’t accidentally double-book a room or event space.

With the release of the Events Calendar 6.2.0, you now have the ability to assign multiple venues to an event. This is a great feature that many users had requested.

While our existing code still works for the first venue added to an event, it does not check for conflicts on any additional venues that are added. Thankfully, in order to get it to work for multiple venues, we only need to add a few lines to our existing code.

This assumes you’ve already implemented our venue-checking code.

We will have to add the following code to our existing dgtlnk-admin.js file.

// Add New Venue Check table row under Venue dropdown when additional venues are added
$('#event_tribe_venue tfoot a.tribe-add-post.button').click(function(){
     setTimeout(function(){
          $("#event_tribe_venue tbody.new-tribe_venue:last-of-type tr.saved-linked-post").after(
"<tr id=\"dgtlnk-venue-check\"><td class=\"dgtlnk-venue-check--label\">Venue Conflicts: </td><td class=\"dgtlnk-venue-check--content\"><p><strong><em>In order to get correct results, please make sure that the Event Start/End date/time has been added, a Venue has been selected before this button is pressed.</em></strong></p><div class=\"dgtlnk-venue-check--content__inner\"></div><a class=\"button\" href=\"#\">Check Now</a><div class=\"dgtlnk-venue-check--loading\" style=\"display:none;\"></div></td></tr>"
          );
     }, 1000);
});

This adds a new table row in the admin with the “Check Now” button whenever the “Add another venue” button is pressed and will continue doing so for any number of additional venues added.

When you click the “Check Now” button under a venue, it will call the existing jQuery click function, which will call the venuecheck_checkVenues function – that in turn makes an AJAX call to check for venue conflicts with other events taking place at the same date/time as the current event at the current selected venue.

If the AJAX callback is successful, it will either return a list of conflicting events or will display a message stating no conflicts were found.

By adding just a few lines of code to the existing checker, you can easily look for venue conflicts for multiple venues in the Events Calendar plugin.

If you need help adding this functionality to your site or need help updating the existing code, reach out to us and we’d be more than happy to assist you in your web development and digital marketing needs.

Avatar photo
About Utsab Karki

Utsab Karki is the Senior WordPress Developer at Digital Ink. He builds new websites, manages functionality requests and changes, and makes clients' sites run better. Digital Ink tells stories for forward-thinking businesses, mission-driven organizations, and marketing and technology agencies in need of a creative and digital partner.

Other Stories You May Like

What’s your story?

Let’s share it with the world.

Let’s Do This

Close Window
All the Cool Kids are Doing it

Sign Up for the Digital Ink Newsletter

All the cool kids are doing it.