I've been researching for days and all I want to be able to do is create entries in the ninja form admin listings. Either by submitting custom form (not ninja form generated) or just calling a hook and passing data (data will match actual form fields created in ninja form).
I want to be able to do this so that I can create any type of form layout and still be able to submit to ninja form entry. Or if anyone has any other information on a plugin that can allow me to do such a thing, please share.
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,
...
);
来源:https://stackoverflow.com/questions/46853980/submit-to-ninja-form-programmatically