I am designing a website intended to list local events. Ideally registered users would be able to upload new events from the front end and the website would display all the upcoming events in chronological order.
I have registered an "Event" custom post type, as a first step, with several custom fields (category, date, time, etc.).
Now I am creating a cron job that loops through the events hourly and removes the ones that have expired.
Finding the events to remove is an easy task.
1) The cron job gets the current date, firstly:
$currentdate= date("Y-m-d");
2) It then gets the starting date of the event (stored in a custom field):
$eventdate = get_field('date');
3) And compares the two with a simple conditional statement:
if ($currentdate > $eventdate ) do something
At this point I would like to make it so that the cron job changes the post type of the expired events to a completely different one - I reckon it would be the best approach (the amount of active events wouldn't progressively increase with time, this way).
My question is then: is there a way to tell Wordpress to change the post type of a post into another?
Thanks in advance for your help :3