I have Custom Post Types which have a vanilla 'date-picker' for each post.
My Custom Posts are actually events that are always in the future.
I'd like to know if I can somehow trigger an alert when an event is over?
I am using a Custom Post Type plugin called "Pods" which is awesome.
Can anyone think of a way to make this happen?
Ideally, I'd have an email sent to me or to trigger a Zapier API call, or similar...
Any ideas on how to approach this?
Thanks!
I have Custom Post Types which have a vanilla 'date-picker' for each post.
My Custom Posts are actually events that are always in the future.
I'd like to know if I can somehow trigger an alert when an event is over?
I am using a Custom Post Type plugin called "Pods" which is awesome.
Can anyone think of a way to make this happen?
Ideally, I'd have an email sent to me or to trigger a Zapier API call, or similar...
Any ideas on how to approach this?
Thanks!
Share Improve this question asked Jul 19, 2019 at 8:53 HenryHenry 9831 gold badge8 silver badges31 bronze badges1 Answer
Reset to default 0You will have to write a plugin which creates a daily cron job in the WordPress system.
Here's an article describing how to write a cron plugin:
https://wpguru.co.uk/2014/01/how-to-create-a-cron-job-in-wordpress-teach-your-plugin-to-do-something-automatically/
The function (callback) that you trigger in the cron plugin will use WP_QUERY to get a list of all your published custom post types after a certain date.
e.g.
$my_query = new WP_Query( array(
'post_type' => 'your-cpt-name-here',
'order' => 'ASC',
'posts_per_page' => 1,
'date_query' => array(
array(
'after' => '1 day',
)
),
) );
Run through the results and send an email using wp_mail()
.
Alternatively, ask on fiver and get a developer to do it for you. It's pretty simple so won't cost very much at all.