How to prevent users from selecting older dates on The Events Calendar

If you have already used the WP User Front-end Plugin to let your users submit any events (using The Tribe Events Calendar plugin). Then you will notice that after publishing the WP User Event form, it will let the users insert any older/previous date for the Event Start/End Field.

But for a few of the users-case, they don’t want to let the author post any older date (Yes, that makes sense!)

So let me show you how you can disable the older/past date from being selected (Yoo! give it to me).

We need a third-party plugin called Custom CSS & JS or any other Code Snippets injection plugin to perform this tweaking. Of course, you can also inject this JQuery code snippet manually, but that requires some technical knowledge, so I’m skipping that for a quick cast.


jQuery(document).ready(function( $ ){
  $('#wpuf-date-_EventStartDate, #wpuf-date-_EventEndDate').datepicker(
            minDate: 0,
           beforeShow: function() {
            $(this).datepicker('option', 'maxDate');

Cheers, that’s fair enough to make the job done!

Note(Explanation): You need to place the proper CSS ID to select the Start & End field. The first #ID for EventStartDate & Second one for EventEndDate input field.

Another thing, this date/time field is a premium feature of WP User Frontend. So you need to purchase the pro version to use the Date/Time field with the WPUF.

Wrapping Up

So if everything is completed nicely, you will notice that the form’s output now only lets the users choose current & future dates, and past dates are disabled.

That’s enough for now. See you in the next post.

MM Aurangajeb
MM Aurangajeb

Spreading Happiness. Support Engineer, WordPress Enthusiast, Blogger.

Articles: 18

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.