重力形成更新先前输入的条目

时间:2016-07-12 17:39:33

标签: wordpress gravity-forms-plugin

遵循这篇文章:

http://techslides.com/editing-gravity-forms-entries-on-the-front-end

尝试获取重力表单以更新提交而不是创建新提交。

问题在于

/* https://www.gravityhelp.com/documentation/article/gform_pre_submission */
add_action("gform_pre_submission", "pre_submission_handler");
function pre_submission_handler($form){

if ( strpos($_SERVER['REQUEST_URI'], 'application-edit', 0) !== false ) {
    //Get original entry id
    parse_str($_SERVER['QUERY_STRING']); //will be stored in $entry

    //get the actual entry we want to edit
    $editentry = GFAPI::get_entry($entry);

    //make changes to it from new values in $_POST, this shows only the first field update
    $editentry[1]=$_POST['input_1'];

    //update it
    $updateit = GFAPI::update_entry($editentry);

    header("Location: http://yourdomain.com/apply/application-thank-you/");

    //dont process and create new entry
    die();
 }

}

代码段,标题重定向不起作用。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

Gravity Forms可以通过 gform_entry_id_pre_save_lead 过滤器更新现有条目。更多信息和用法示例:

https://www.gravityhelp.com/documentation/article/gform_entry_id_pre_save_lead/#examples