Expire Requests based on a newly created 'Date' attribute

Hi @andrii

I created a date attribute in ‘requests’ called ‘event_date’
I’d like the requests to expire on that date that the user submits.
Is this possible please?

I found this code, but wasn’t sure if it was suitable if I modify it for the requests instead?
How to expire a listing with the date attribute given by the user

add_action(
	'hivepress/v1/models/listing/update',
	function( $listing_id, $listing ) {
		if ( $listing->get_custom_expired_time() ) {
			update_post_meta($listing_id, 'hp_expired_time', strtotime($listing->get_custom_expired_time()));
		}
	},
	10,
	2
);

Many thanks :slight_smile:

Hi,

Yes, it can actually work if you replace all the “listing” occurrences with “request” in this code snippet, and also make sure that the custom date attribute you added has the “custom_expired_time” field name (or change it in the code to match the custom Date attribute field name).

1 Like