How to prevent users to select older date 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.

How to prevent users to select older date on The Events Calendar 1

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).

To perform this tweaking we need a third-party plugin called Custom CSS & JS or any other Code Snippets injection plugin. You can also inject this JQuery code snippet manually but that requires a little bit technical knowledge so I”m skipping that for a quick cast.

Process

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 right 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 completed nicely then you will notice the output of the form now only let the users chose current & future dates and past dates are disable.

How to prevent users to select older date on The Events Calendar 2

That’s enough for now, see you on the next post. 🙂

Default image
MM Aurangajeb
Support Engineer, Blogger. Learning Web Design & Developing, Tech & WordPress Enthusiast, WordPress Lover. Always try to learn new things, new hacks, new techs.

Newsletter Updates

Enter your email address below to subscribe to our newsletter

Leave a Reply

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