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.

Creating Publish Date from Date Field?

  1. johnny9k
    Member

    I would like to have the date field determine the publish date of the new post. Is this possible?

    Posted 14 years ago on Thursday November 5, 2009 | Permalink
  2. Currently this isn't possible. We will add it to our feature ideas list and could potentially add it as a feature in a future release.

    Posted 14 years ago on Thursday November 5, 2009 | Permalink
  3. johnny9k
    Member

    Thanks Carl. This would be a boon for a site I am working on. User submitted posts with a scheduled publish date. Wordpress can then show upcoming posts in order of the date entered by the user (event date). Perfect for upcoming events.

    Posted 14 years ago on Friday November 6, 2009 | Permalink
  4. Is this possible yet? I really need to be able to do this.

    Posted 12 years ago on Monday January 16, 2012 | Permalink
  5. Can this be done with http://www.gravityhelp.com/documentation/page/Entry_Object? Using "$entry["date_created"];"? If so, can I get some example code? I'm not 100% sure how to do this.

    Posted 12 years ago on Monday January 16, 2012 | Permalink
  6. Bump... Anyone?

    Posted 12 years ago on Monday January 16, 2012 | Permalink
  7. Bump. Can someone please help.

    Posted 12 years ago on Wednesday January 18, 2012 | Permalink
  8. I've been trying to get support everyday since Monday. This is pathetic. I wouldn't have paid for this service if I would have known it would be this hard to do such easy things...

    Can someone please help.

    Posted 12 years ago on Thursday January 19, 2012 | Permalink
  9. bump...

    Posted 12 years ago on Thursday January 19, 2012 | Permalink
  10. Hi, bluetidepro,

    We are sorry about the delay in responding as we have been working on Priority Support requests. We normally respond sooner than this. If you want to set what the publish date will be on the post you can do something similar to below. This code sets the post date/time based on fields on the form. In my example I have set a future date so the post winds up being "Scheduled" with the date/time chosen on the form as the "Scheduled for" date. Let me know if you have questions about the code.

    add_filter("gform_post_data", "set_post_date", 10, 2);
    function set_post_date($post_data, $form){
        //only do this when the form id is 23
        if($form["id"] != 23)
           return $post_data;
    
    	//set post date to field on form if date provided; get from POSTed data
    	//using a date field in mm/dd/yyyy format and a time field in 24 hour format
    	$date_value = rgpost("input_6"); //pull the date value from the form data posted, field 6 on my form
    	$time = rgpost("input_7"); //pull the time value from the form data posted, field 7 on my form
    	//only change post date/time when a date has been chosen
    	if (!empty($date_value))
    	{
    		if (empty($time))
    		{
    			//set default time
    			$time_value = "00:00:00";
    		}
    		else
    		{
    			empty($time[0]) ? $time_hours = "00" : $time_hours = $time[0]; //pull hours out of array
    			empty($time[1]) ? $time_minutes = "00" : $time_minutes = $time[1]; //pull minutes out of array
    			$time_value = $time_hours . ":" . $time_minutes . ":00"; //add on seconds
    		}
    		//convert post date to the appropriate format so it will be inserted into the database
    		$post_date = date("Y-m-d H:i:s",strtotime($date_value . " " . $time_value));
    
        	$post_data["post_date"] = $post_date; //set the post_date
    	}
        return $post_data; //return the changed data to use when the post is created
    }
    Posted 12 years ago on Thursday January 26, 2012 | Permalink

This topic has been resolved and has been closed to new replies.