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 Detail Page

      The Event detail page carries various details of a particular event. These details include the event title, event type, event location, event start date & time, event end date & time, event description, etc. besides this, you can also get the details ...
    • Installation of WP Event Manager

      Automatic Installation of FREE WP Event Manager Installing WP Event Manager is just a matter of a few clicks. You can add WP Event Manager to your website by using the dashboard offered to you at the backend of the CMS. To install the plugin ...
    • Ordering Events By Event Start Date / meta key

      WP Event Manager allows its users to arrange events in order and change the order as per their requirements. In this guide, you will learn about how you can arrange events in order based on their start date/ meta key. Here are the steps you need to ...
    • Changing the event slug/permalink

      In this guide, we will show you how you can change or customize the event slug or permalink. It usually appears like this: http://yoursite.com/events/event-listing-title in the default settings. To customize this with WP Event Manager, you can use ...
    • How to delete an expired event by time

      In Order to display an event as Expired after a specific date and time, you need to add the following code to your theme functions.php file. Open your child theme, Add the code into the funtions.php file. /* Event Expire by time */ function ...