How to Build a JSON payload with Ninja Forms Data - PixelPowerLLC/NinjaForms---Addon-MailChimp-Multi-Referral GitHub Wiki

The data flow

  1. User submits Ninja form with data
  2. Ninja Forms “WordPress Hook” Calls a WordPress Custom Action setup in functions.php
  3. The WordPress Custom Action in functions.php passes the Ninja Forms data object to the assigned callback function.

Ninja Forms WordPress Hook

In your Ninja Form setting go to Emails & actions then click the box labeled “WP Hook”. In the “WP Hook” settings the box labeled “Hook Tag” must match the custom action you create in functions.php.

WordPress Custom Action

Open the WordPress theme functions.php file and scroll to the bottom.

First we need to add the action name and the callback function name. In the example below the first parameter “my_special_action” is the custom action name. This string must match the Ninja Forms “Hook Tag”. The second parameter is the php function name that will be called when this action is triggered.

add_action( 'my_special_action', 'call_back_function' );

Next we add our call back function code.

function call_back_function( $data ) {
    
    //Code to build data payload goes here.
}
⚠️ **GitHub.com Fallback** ⚠️