I have created a custom attribute called Event End Date that the user defines. I would like their listing to expire and be removed from the listings page one day after this date. I am using the below snippet, but it isn’t working:
add_action(
'hivepress/v1/models/listing/update',
'custom_update_expiration_date',
10,
2
);
function custom_update_expiration_date($listing_id){
remove_action( 'hivepress/v1/models/listing/update', 'custom_update_expiration_date', 10, 2 );
$listing = \HivePress\Models\Listing::query()->get_by_id($listing_id);
if(!$listing){
return;
}
$end_time = $listing->get_attribute_field_name();
if(!$end_time){
return;
}
$listing->set_expired_time(strtotime('+2 days', strtotime($end_time)))->save_expired_time();
}