Trigger WP CRON from a date in a Custom Field?

I have Custom Post Types which have a vanilla 'date-picker' for each post.My Custom Posts are actually events

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 badges
Add a comment  | 

1 Answer 1

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745311608a4622025.html

相关推荐

  • Trigger WP CRON from a date in a Custom Field?

    I have Custom Post Types which have a vanilla 'date-picker' for each post.My Custom Posts are actually events

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信