PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Scheduling the Post Date

  1. I've read through the forums thoroughly and tried a few of the things I've seen, but wasn't able to get it to work.

    I have a form that is posting to a custom post type. The form creates directory listings. The directory listing page templates only show posts in the future, so I'm trying to have the form post a date that is equal to today's date plus a year. The posts are going through okay but the date is not being changed. This is my current functions code:

    add_filter('gform_pre_submission', 'set_post_date', 10, 2);
    function set_post_date($post_data, $form){
    			return $post_data;
    			$today_date = date('Y-m-d'); /** CURRENT DATE*/
    			$time_value = date('H:i:s'); /** CURRENT TIME*/
    			$date_value = strtotime(date('Y-m-d', strtotime($today_date)) . '+1 year'); /** ADJUSTED DATE*/
    			$post_date = date("Y-m-d H:i:s",strtotime($date_value . " " . $time_value));
    			$post_data["post_date"] = $post_date;
    			return $post_data;

    I also tried setting my filter to gform_post_data but that didn't change anything either.

    Am I using the wrong filter to affect the post date?

    All the Best,

    Posted 9 years ago on Saturday June 16, 2012 | Permalink
  2. Wouldn't you have to change the post_status to future as well, instead of publish, in addition to setting the date in the future?

    Posted 9 years ago on Monday June 18, 2012 | Permalink