Customize Event Expiry Date and Time

Customize Event Expiry Date and Time

As per our plugin functionality, the owner of a website or the admin can set the event expiry date either on the day of the event end date or can choose his or her preferred date, Here, it is to be mentioned that only the date can be modified and the time will be the same 23:59:30.

Event Organizers do not have the rights to set the expiry date, so when they post an event from the frontend, the expiry date automatically is set to the same as the event data and time remains 23:59:30.

To avoid this and allow event organizers and other users to set or customize the event expiry date we have a few code and filters which are mentioned below.

1. If you want to keep the event expiry date-time same as the event end date-time then you need to write the below-mentioned code in your theme functions.php file:

1
2
3
4
5
6
7
add_filter('wpem_expire_date_time', 'wpem_change_expire_date_time', 10, 2);
function wpem_change_expire_date_time($expire_date, $event){
 
this will return event end date and time to expire event
 
return $event->_event_end_date;
}

2. Usually the default time zone is taken based on your server time, so If you want to set the event expiry date-time based on your specific country timezone, then you need to paste the below mentioned code in your theme functions.php file.

01
02
03
04
05
06
07
08
09
10
11
add_filter('wpem_get_current_expire_time', 'get_current_date_time');
function get_current_date_time($date){
 
this will return your current date and time
you need to pass your timezone string here
 
date_default_timezone_set('Asia/Kolkata');
 
return date("Y-m-d H:i:s");
 
}

3. If you want to set  a completely different date and time for the event expiry from the event end date-time then  you first  need to add a custom field for the event “Expiry Date” and “Expiry Time” in your event field editor from the back-end. Then you need to add the below-mentioned code in your theme functions.php file:

1
2
3
4
5
6
7
add_filter('wpem_expire_date_time', 'wpem_change_expire_date_time', 10, 2);
function wpem_change_expire_date_time($expire_date, $event){
 
this will return event expire date and time as per user added in custom field
 
return $event->_expire_date.' '.$event->_expire_time;
}

In the above code you need to write the event expiry date meta_key in place of “_expire_date” and event expiry time meta key in place of “_expire_time”.


    • Related Articles

    • Event Countdown

      The countdown plugin allows you to display a countdown timer on your events, registration and ticket selling page to keep your audiences updated about the time left for the event, registration and ticket availability. Installation The installation ...
    • The event submission form

      To display the Event Submission Form, a user needs to create a new page from the Pages menu at the Admin Panel and then add the shortcode [submit_event_form]. A user can also add the shortcode in the Template File which is attached to the page ...
    • Event Calendar

      An interactive calendar that stylishly displays your upcoming event dates and details. Installing The Plugin The installation process is the same for all the addons, offered by WP Event Manager. They can be both installed automatically and manually. ...
    • Event Fields

      Event Submission Form Custom Fields Settings The field editor sub-menu under Event Listings (WP Admin>> Event Manager >> Field Editor) offers flexibility to edit field labels including Type of data, description, placeholder and more. The settings ...
    • Event Slider

      The sliders plugin helps users display their events in slider forms at the front end of the website along with the event image, event title, organizer name, and description. The slider plugin comes with responsive designs that are suitable for all ...