fbpx
Participate in our upcoming live webinar on WP Event Manager CRM plugins on 29th May at 10pm IST. Register Now!
How can we help?

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:

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.

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:

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

Customize Event Expiry Date And Time
Editorial Team

Our team constantly explores ways that technology can help us reinvent industries. We want to change the world by creating great products that transform industries. We Dream It, We Make It.

Quick Links
Close
Close