Integrating Ninja Forms with SendSquared: A Technical Overview

The following code hooks into the `ninja_forms_after_submission` action in Ninja Forms, which is triggered after a form is submitted. It collects the form data, sets up the API data, and uses `wp_remote_post` to send the data to the API. The code also checks the response code to ensure that the data was successfully sent to the API. If there is an error, it logs the error.

Note: You will need to replace your-email-field-id and your-name-field-id with the actual field IDs for the email and name fields, respectively, and your-list-group-uuid with the actual UUID of the list group the user will subscribe to.

add_action('ninja_forms_after_submission', 'custom_form_submission');
function custom_form_submission($form_data)
    // Get the form data
    $email = $form_data['fields']['your-email-field-id']['value'];
    $name = $form_data['fields']['your-name-field-id']['value'];

    // Set the API URL with the token
    $token = "your-list-group-uuid";
    $api_url = "$token";

    // Set up the API data
    $api_data = array(
        "email" => $email,
        "name" => $name,

    // Use wp_remote_post to send the data to the API
    $response = wp_remote_post($api_url, array(
        "body" => $api_data

    // Check the response code
    if (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200) {
        // Log an error
        error_log("Error submitting form: " . print_r($response, true));

If you have any additional questions, feel free to reach out to SendSquared support.

Leave a Reply

Your email address will not be published. Required fields are marked *