Custom Form Action

The “Custom” form action type allows you to hook a WordPress action into form processing.

Add Custom Form Action

The “Hook Tag” setting specifies what WordPress action hook to call during the submission process.

Custom Form Action

During submission the specified “Hook Tag” is passed a $form_data array variable. This array contains the form id, form fields, and form settings data as top level keys in the array.

Notice: The $ninja_forms_processing super global has been removed. All form data is available via the passed $form_data parameter.

<?php
/**
* @tag my_ninja_forms_processing
* @callback my_ninja_forms_processing_callback
*/
add_action( 'my_ninja_forms_processing', 'my_ninja_forms_processing_callback' );
/**
* @param $form_data array
* @return void
*/
function my_ninja_forms_processing_callback( $form_data ){
$form_id = $form_data[ 'form_id' ];
$form_fields = $form_data[ 'fields' ];
foreach( $form_fields as $field ){
$field_id = $field[ 'id' ];
$field_key = $field[ 'key' ];
$field_value = $field[ 'value' ];
// Example Field Key comparison
if( 'my_field' == $field[ 'key' ] ){
// This is the field that you are looking for.
}
}
$form_settings = $form_data[ 'settings' ];
$form_title = $form_data[ 'settings' ][ 'title' ];
}

Note that the callback cannot update the submitted form data as this is a WordPress action and not a filter. The callback method should be a void return method.