Home Forums Feature Requests ACF date field email reminder


ACF date field email reminder

  • Hello,

    I am building a website, where i am using acf with custom post type.
    Users are required to fill up a form, booking a date ( a field [acf-date] ) to visit a school.

    I used the ‘Advanced Custom Fields Contact Forms’ so now i get notified when a user submits a form.

    Now the tricky part is that i need the form to send a reminder email with 2 days before the date he selected in the form [acf-date].

    Then that email to go to me and to him as well.

    I tryed using the wp cron, but could notfigure it out, plus ,from what i understand, it requires that the user should visit the site dayly, in order for the cron job to function.

    Now i am thinking at this:
    -change post pubish date to [acf-date] – 2days
    -create a function that notifies me and the user at the time of the publishing.

    The problem is that i do not know how to change the publishing date to 2 days before the selected [acf-date].

    Can anyone help me?

    Thank you!

  • Hi @viorelepuran

    The scheduling of a post works the same as any wp cron so it would not make any difference if no one visits your site. I think the right way to go is to create your own cron job as you initially thought.

    To make wp cron more reliable is actually pretty simple if you have access to cron on your server/hosting.

    I don’t know what “Advanced Custom Fields Contact Forms” is but I assume it’s a third party plugin. I will assume it creates a CPT which all the submissions are saved to as posts.

    I would create a cron job that triggers a function. In the function you query the submissions for date values where the date is in two days from today. Then in the loop you find the users email and send out an email using wp_mail. It’s all fairly simple if you’re familiar with PHP 🙂

    Here’s how to get a date two days from now:
    $date = date('Ymd', strtotime('+2 days'));

    and a query

    $upcoming_query = new WP_Query(array(
    	'post_type' => 'submissions' //whatever it is
    	'meta_query' => array(
    		'key' => 'acffield',
    		'value' => $date,
    		'compare' => '='
    	'posts_per_page' => 100,
    	'no_found_rows' => true,
    	'update_post_term_cache' => false
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘ACF date field email reminder’ is closed to new replies.