submit to ninja form programmatically

蓝咒 提交于 2019-12-06 15:46:59

In NinjaForms version 3, you probably want to look at this file:

ninja-forms/includes/Actions/Save.php

The process function contains the important bits that may help you:

$sub = Ninja_Forms()->form( $form_id )->sub()->get();

foreach($fields as $field_id => $field_value){
    $sub->update_field_value( $field_id, $field_value );
}

$sub->save();

In NinjaForms version 2, it is a little different

$sub_id = Ninja_Forms()->subs()->create( $form_id );

foreach( $form_fields as $field_id => $value ) {

    Ninja_Forms()->sub( $sub_id )->add_field( $field_id, $value );
}

Where the $form_fields array would look like:

$form_fields = array(

    $fiel_id_1 => $value_1,
    $fiel_id_2 => $value_2,
    ...

);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!