0

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!

0

You 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.com and get a developer to do it for you. It's pretty simple so won't cost very much at all.

  • Amazing thanks Wil Brown really helpful – henry Jul 19 '19 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.