0
好的,我的代碼工作很好,但我仍然必須進入並更改發佈狀態從待處理髮布。有什麼辦法可以預定嗎?這裏是代碼:如何使郵政計劃,而不是掛起 - 重力形式
add_filter('gform_field_value_rprs_day', 'populate_day');
add_filter('gform_field_value_rprs_time', 'populate_time');
/**
* Automatically populate the current day and time on the submission page.
*
* @link http://www.gravityhelp.com/forums/topic/defaultdynamic-value-for-time
* @link http://borishoekmeijer.nl/resolve-current-date-and-time-timezone-issue-in-wordpress/
*/
function populate_day($value) {
return date('m/d/Y');
}
function populate_time($value) {
return date('g:i a', current_time('timestamp'));
}
add_filter("gform_post_data", "rns_set_press_release_date_and_time", 10, 3);
/**
* Set the date and time of a submitted Press Release.
*
* @link http://www.gravityhelp.com/documentation/page/Gform_post_data
*/
function rns_set_press_release_date_and_time($post_data, $form, $entry){
//only do this when the form id is 1
if($form["id"] != 1)
return $post_data;
//set post date to field on form if date provided; get from entry data
//using a date field in mm/dd/yyyy format and a time field in 24 hour format
$day = $entry["2"]; //pull the date value from the form data posted
$time = $entry["11"]; //pull the time value from the form data posted, field 7 on my form
// Set the day to what we put in the field
$day_value = date("Y-m-d", strtotime($day));
// Set the hours, minutes, and seconds to what we put in the field
$time_hours = $time[1];
// Search for "pm" in our time variable, and add 12 to the hours if we find it.
if (strpos($time, "pm")) {
$time_hours = $time_hours + 12;
}
$time_minutes = $time[3] . $time[4];
$time_value = $time_hours . ":" . $time_minutes . ":00";
// Set the post_date variable after we have our final date and time
$post_date = $day_value . " " . $time_value;
// $post_data["post_title"] = $time[0] . "1 is " . $time[1] . "2 is " . $time[2] . "3 is " . $time[3] . "4 is " . $time[4];
$post_data["post_date"] = $post_date; // Change the post_date property to our post_date variable
$post_data["post_date_gmt"] = get_gmt_from_date($post_date); //set the post_date_gmt
return $post_data; //return the changed data to use when the post is created
}
是否有一條線,我可以更改/添加,使它成爲一個預定的職位?
你是什麼意思的 「計劃」 嗎?這是一個狀態名稱,還是你希望這個代碼在特定的時間運行? – halfer 2014-09-19 21:25:17