2014-09-19 1 views
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 
} 

예약 된 게시물로 변경/추가 할 수있는 행이 있습니까?

+0

당신은 "계획"은 무엇을 의미합니까? 상태 이름입니까, 아니면이 코드를 특정 시간에 실행 하시겠습니까? – halfer

답변

0

은 내가 여기 니펫을 작업하는 기사를 작성했습니다 :

http://gravitywiz.com/schedule-post-date-field-gravity-forms/

당신은 전에 (현재, 나는 다음 행을 추가 믿고 작업중인 조각을 사용하기 원하는 경우 문) "반환" 그것이 작동되도록해야합니다

$post_data['edit_date'] = true; 
관련 문제