Search code examples
wordpresseditsubmissionninja-forms

WordPress - Ninja Forms: How to edit a saved Submission Programatically?


I have a form say Form_ID=9. I want to edit Field_id:50 (lable: status) of a specific submission say Sub_id:160.

I can access that piece of information with custom code on a custom template page (front-end) but couldn't find a way to Update (or edit or modify, whatever you say) a field in a particular submission. Even Ninja Support refused to help.

Any CODE NINJA who could help?


Solution

  • Finally figured it out. Please note now I am using Ninja Forms 3.0.2 and this approach is for 3 on-wards (not tested < v3).

    This is how to edit a field in as already saved form:

    $result = Ninja_Forms()->sub( $sub_id )->update_field( 50, $status );

    So for my example above it will become:

    $result = Ninja_Forms()->sub( 160 )->update_field( 50, $status ); // 50 is field id and $status is the updated value.

    Enjoy..