Article Overview
- Category: Developer API, Theme / Child Theme Integration, Custom Plugins & Extensibility
- Audience: WordPress Developers, Theme Authors, Agency Engineers, Enterprise System Integrators
- Applies To: NextGen Smart Data Importer (Community Free & Enterprise Pro Editions)
- Purpose: Definitive technical reference and integration guide explaining how developers can hook into, extend, customize, and automate NextGen Smart Data Importer from child themes, custom plugins, or headless microservices.
- Related Guides:
1. Executive Summary
NextGen Smart Data Importer was engineered with a hook-first, modular architecture. Rather than being a closed black-box importer, every stage of the parsing, mapping, record creation, image sideloading, and cleanup pipeline exposes native WordPress action and filter hooks.
In fact, the NextGen Pro Add-On itself is built entirely as a client of these public hooks and APIs—demonstrating that third-party developers have first-class access to customize or intercept any behavior.
Developers can extend NextGen Importer from:
- Child Themes (
functions.php): Lightweight site-specific adjustments (custom pricing rules, formatting values, triggering webhooks). - Custom / Site-Specific Plugins: Full-fledged custom add-ons registering custom mapping fields into the React interface.
- Headless / Microservice Scripts: Programmatic import triggers via WP-CLI or the WordPress REST API.
- Built-in In-App Function Editor: Native browser-based PHP snippet runner with built-in exception handling.
2. Import Execution Lifecycle Architecture
3. Core Action Hooks (do_action)
Developers can subscribe to these actions using the standard WordPress add_action() function.
3.1. nextgen_importer_before_import_row
Fires immediately before an individual spreadsheet row is processed.
- Arguments:
$row(array): Key-value associative array of the raw incoming source row data.$importer(NextGen_Base_Importer): Active importer instance containing settings and mapping rules.$import_id(string): Unique import session identifier (e.g.import_6afe8b...).
add_action('nextgen_importer_before_import_row', function ($row, $importer, $import_id) {
// Example: Log custom telemetry for external audit
if (!empty($row['sku'])) {
error_log("[NextGen Import {$import_id}] Starting ingestion for SKU: " . sanitize_text_field($row['sku']));
}
}, 10, 3);3.2. nextgen_importer_after_post_import
Fires immediately after a WordPress Post, Page, or Custom Post Type (CPT) has been inserted or updated.
- Arguments:
$post_id(int): Newly created or updated WordPress post ID.$row(array): Raw incoming row array.$importer(NextGen_Base_Importer): Active importer instance.
add_action('nextgen_importer_after_post_import', function ($post_id, $row, $importer) {
// Example: Dispatch webhook to external CRM / ERP
if (get_post_type($post_id) === 'product') {
wp_remote_post('https://api.my-erp.com/v1/product-synced', array(
'blocking' => false,
'headers' => array('Content-Type' => 'application/json'),
'body' => wp_json_encode(array(
'wordpress_post_id' => $post_id,
'external_erp_id' => $row['erp_reference_code'] ?? null,
'synced_at' => current_time('mysql'),
)),
));
}
}, 10, 3);3.3. nextgen_importer_after_term_import
Fires after a Category, Tag, or Custom Taxonomy term is created or updated.
- Arguments:
$term_id(int): ID of the term.$taxonomy(string): Taxonomy slug (e.g.category,product_cat,genre).$row(array): Source spreadsheet row.$mapping(array): Active field mapping array.$importer(NextGen_Base_Importer): Importer instance.
add_action('nextgen_importer_after_term_import', function ($term_id, $taxonomy, $row, $mapping, $importer) {
// Example: Update custom term meta from unmapped CSV columns
if (!empty($row['custom_hex_color'])) {
update_term_meta($term_id, 'brand_color_hex', sanitize_hex_color($row['custom_hex_color']));
}
}, 10, 5);3.4. nextgen_importer_after_user_import
Fires after a WordPress User account is imported.
- Arguments:
$user_id(int): WordPress user ID.$row(array): Incoming source row.$mapping(array): Mapping rules.$importer(NextGen_Base_Importer): Importer instance.
add_action('nextgen_importer_after_user_import', function ($user_id, $row, $mapping, $importer) {
// Example: Assign custom membership level or send custom welcome email
if (!empty($row['membership_tier'])) {
update_user_meta($user_id, '_custom_membership_level', sanitize_text_field($row['membership_tier']));
}
}, 10, 4);3.5. nextgen_importer_after_comment_import
Fires after a Comment or WooCommerce Review is created.
- Arguments:
$comment_id(int): Created comment ID.$row(array): Source row.$importer(NextGen_Base_Importer): Importer instance.
3.6. nextgen_import_completed
Fires when an entire import session finishes processing all rows (whether executed via browser Ajax, background WP-Cron, or WP-CLI).
- Arguments:
$import_id(string): Session ID of the completed job.
add_action('nextgen_import_completed', function ($import_id) {
// Example 1: Flush server-side reverse proxy caches
if (function_exists('wp_cache_flush')) {
wp_cache_flush();
}
// Example 2: Notify team via Slack incoming webhook
wp_remote_post('https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK', array(
'blocking' => false,
'headers' => array('Content-Type' => 'application/json'),
'body' => wp_json_encode(array(
'text' => "🚀 NextGen Importer job `{$import_id}` completed successfully on " . home_url(),
)),
));
});4. Core Filter Hooks (apply_filters)
Filters allow developers to inspect, modify, or completely override data before it is written to the database.
4.1. nextgen_importer_field_value
Mutates any field value before saving.
- Arguments:
$value(mixed): Resolved field value after standard mapping.$target_field(string): Target database field key (e.g.post_title,post_content,_regular_price).$row(array): Raw incoming row data.
add_filter('nextgen_importer_field_value', function ($value, $target_field, $row) {
// Enforce proper uppercase SKU conventions
if ($target_field === '_sku' && is_string($value)) {
return strtoupper(trim($value));
}
// Automatically sanitize and normalize phone numbers
if ($target_field === 'billing_phone' && is_string($value)) {
return preg_replace('/[^0-9+]/', '', $value);
}
return $value;
}, 10, 3);4.2. nextgen_importer_import_types
Adds custom import targets to the NextGen Setup Wizard dropdown.
- Arguments:
$types(array): Associative array of available target types (key => Human Label).
add_filter('nextgen_importer_import_types', function ($types) {
$types['crm_leads'] = __('Salesforce CRM Leads (Custom)', 'my-theme');
$types['invoices'] = __('Legacy Accounting Invoices', 'my-theme');
return $types;
});4.3. nextgen_importer_product_price
Dynamically adjusts WooCommerce product regular or sale prices on ingestion.
- Arguments:
$price(string|float): Ingested price.$row(array): Source spreadsheet row.
add_filter('nextgen_importer_product_price', function ($price, $row) {
if (empty($price) || !is_numeric($price)) {
return $price;
}
// Example: Apply a 15% wholesale margin markup on imported cost
if (!empty($row['supplier_cost'])) {
return number_format(floatval($row['supplier_cost']) * 1.15, 2, '.', '');
}
return $price;
}, 10, 2);5. Third-Party UI Extension: NextGen_Addon_API
NextGen provides the NextGen_Addon_API class, allowing third-party plugins to inject their own custom field cards directly into the React Drag-and-Drop Mapping Wizard.
When registered, NextGen's React application fetches these fields via the REST API and renders them with full search, drag-and-drop, and AI auto-mapping capabilities.
5.1. Registering Custom Addon Fields
Place this inside your custom plugin or child theme:
add_action('init', function () {
if (class_exists('\\Frexten\\NSDI\\NextGen_Addon_API')) {
\Frexten\NSDI\NextGen_Addon_API::register_addon(
'custom_erp_bridge',
__('ERP Sync Meta', 'my-custom-plugin'),
array(
array(
'key' => 'erp_warehouse_bin',
'label' => __('Warehouse Bin Location', 'my-custom-plugin'),
'type' => 'text',
'description' => __('Aisle/shelf coordinate for inventory picking.', 'my-custom-plugin'),
),
array(
'key' => 'erp_tax_code',
'label' => __('Avalara Tax Code', 'my-custom-plugin'),
'type' => 'text',
'description' => __('Enterprise tax category identifier.', 'my-custom-plugin'),
),
array(
'key' => 'erp_hazmat_flag',
'label' => __('Hazardous Material Flag', 'my-custom-plugin'),
'type' => 'boolean',
'description' => __('Set to 1 or true for restricted shipping.', 'my-custom-plugin'),
),
)
);
}
});5.2. Persisting the Ingested Custom Fields
Hook into nextgen_importer_after_post_import to persist the mapped values:
add_action('nextgen_importer_after_post_import', function ($post_id, $row, $importer) {
$mapping = $importer->get_mapping();
// Check if the user mapped the 'erp_warehouse_bin' field
if (!empty($mapping['erp_warehouse_bin']) && isset($row[$mapping['erp_warehouse_bin']])) {
$bin_code = sanitize_text_field($row[$mapping['erp_warehouse_bin']]);
update_post_meta($post_id, '_warehouse_bin', $bin_code);
}
}, 10, 3);6. Built-in In-App Function Editor
For sites where developers do not have direct FTP or Git repository access, NextGen provides a built-in Custom Function Editor in the admin dashboard:
- Storage Location: Code snippets are written to
wp-content/uploads/nextgen-importer/functions.php. - Execution Safety: The plugin loads this file on
plugins_loadedwrapped inside an isolatedtry / catch (\Throwable)block, ensuring that syntax mistakes in user snippets never bring down the WordPress site or cause fatal errors.
7. Headless & Programmatic Automation
7.1. WP-CLI Command-Line Automation
NextGen registers the wp nextgen-importer command family (along with convenient aliases wp nextgen and wp nsdi):
# Run a specific saved import session
wp nextgen-importer run import_6afe8b519e65b --user=1
# Check the status and progress of scheduled jobs
wp nextgen-importer status
# Cancel or pause an active import
wp nextgen-importer pause import_6afe8b519e65b7.2. WordPress REST API Endpoints
Developers can trigger, inspect, or abort imports from external scripts (Node.js, Python, Zapier, Make):
GET /wp-json/nextgen/v1/imports— List all scheduled and historical imports.POST /wp-json/nextgen/v1/imports/schedule— Create and trigger a new import session.POST /wp-json/nextgen/v1/imports/{import_id}/pause— Pause execution.POST /wp-json/nextgen/v1/imports/{import_id}/resume— Resume execution.GET /wp-json/nextgen/v1/failed-rows/{import_id}— Query granular rejected row payloads.
8. Complete Boilerplate: Custom Bridge Plugin
Developers can package their customizations as a standalone WordPress plugin. Below is a complete, production-ready template:
<?php
/**
* Plugin Name: NextGen Importer - Custom ERP Bridge
* Description: Demonstrates custom hooks, field registration, and post-import webhooks for NextGen Smart Data Importer.
* Version: 1.0.0
* Author: Engineering Team
* License: GPL-2.0+
*/
if (!defined('ABSPATH')) {
exit;
}
// 1. Register custom fields in NextGen React UI
add_action('init', function () {
if (class_exists('\\Frexten\\NSDI\\NextGen_Addon_API')) {
\Frexten\NSDI\NextGen_Addon_API::register_addon(
'erp_bridge',
'Acme ERP Connect',
array(
array(
'key' => 'acme_supplier_id',
'label' => 'Acme Supplier ID',
'type' => 'text',
'description' => 'Supplier account code from ERP',
),
)
);
}
});
// 2. Format field values on-the-fly
add_filter('nextgen_importer_field_value', function ($value, $field, $row) {
if ($field === 'post_title' && is_string($value)) {
return ucwords(strtolower(trim($value))); // Title case
}
return $value;
}, 10, 3);
// 3. Post-import record processing
add_action('nextgen_importer_after_post_import', function ($post_id, $row, $importer) {
if (!empty($row['acme_supplier_id'])) {
update_post_meta($post_id, '_acme_supplier_id', sanitize_text_field($row['acme_supplier_id']));
}
}, 10, 3);
// 4. Job completion notification
add_action('nextgen_import_completed', function ($import_id) {
error_log("[NextGen] Completed import job: {$import_id}");
});9. Summary & Quick Reference Table
| Capability | Hook / Class | File / Location | Primary Use Case |
|---|---|---|---|
| Pre-Row Interception | nextgen_importer_before_import_row |
do_action |
Validate raw CSV columns or log audit metrics |
| Post-Row Entity Hook | nextgen_importer_after_post_import |
do_action |
Update custom DB tables or dispatch ERP webhooks |
| Taxonomy Hook | nextgen_importer_after_term_import |
do_action |
Populate custom term meta |
| User Ingestion Hook | nextgen_importer_after_user_import |
do_action |
Membership assignments or custom user meta |
| Job Completion Hook | nextgen_import_completed |
do_action |
Clear Varnish/Redis cache or send Slack alerts |
| Value Sanitizer / Mutator | nextgen_importer_field_value |
apply_filters |
Clean up dates, format phone numbers, uppercase SKUs |
| Custom UI Addon Registry | NextGen_Addon_API::register_addon |
PHP Class | Expose custom fields in React drag-and-drop mapper |
| CLI Automation | wp nextgen-importer |
WP-CLI | Headless cron automation or DevOps deployments |
| REST API | /wp-json/nextgen/v1/... |
REST Endpoints | External SaaS or microservice orchestration |