Forms

Below are the hooks found in your form hook. I excluded WordPress default hooks, AJAX hooks, REST hooks, and location/line references as requested.

Hooks Summary

Hook NameTypePurpose
nextcrm/form/createActionRuns after a new form is created.
nextcrm/form/updateActionRuns after an existing form is updated.
nextcrm/form/deleteActionRuns after a form is deleted.
nextcrm/form/deactivateActionRuns after a form status is changed between active/deactive.
nextcrm/form/per_pageFilterControls fallback form list pagination limit.
nextcrm/forms/statusFilterAllows modifying form status labels.

nextcrm/form/create

Runs after a new form is created successfully.

Code Ref

do_action('nextcrm/form/create', $form_id);

Parameters

ParameterTypeDescription
$form_idintNewly created form ID.

Example Usage

add_action('nextcrm/form/create', 'my_after_nextcrm_form_create', 10, 1);

function my_after_nextcrm_form_create($form_id) {
    error_log('New NextCRM form created. Form ID: ' . $form_id);

    // Example: get form data
    $form = nextcrm_manager()->forms->get_form_by_id($form_id);

    if ($form) {
        error_log('Form title: ' . $form->title);
    }
}

Developer Use Cases

Use this hook to:

// Start custom automation
// Sync form data with external app
// Add default tracking meta
// Send admin notification

nextcrm/form/update

Runs after an existing form is updated successfully.

Code Ref

do_action('nextcrm/form/update', $form_id);

Parameters

ParameterTypeDescription
$form_idintUpdated form ID.

Example Usage

add_action('nextcrm/form/update', 'my_after_nextcrm_form_update', 10, 1);

function my_after_nextcrm_form_update($form_id) {
    $form = nextcrm_manager()->forms->get_form_by_id($form_id);

    if (!$form) {
        return;
    }

    error_log('Form updated: ' . $form->title);
}

Developer Use Cases

Use this hook to:

// Clear custom form cache
// Update external form records
// Log form changes
// Rebuild embed data

nextcrm/form/delete

Runs after a form is deleted.

This hook is used for both single form delete and bulk form delete.

Code Ref

Single delete:

do_action('nextcrm/form/delete', $form_id);

Bulk delete:

foreach( $form_ids as $form_id ){
    do_action('nextcrm/form/delete', $form_id);
}

Parameters

ParameterTypeDescription
$form_idintDeleted form ID.

Example Usage

add_action('nextcrm/form/delete', 'my_after_nextcrm_form_delete', 10, 1);

function my_after_nextcrm_form_delete($form_id) {
    error_log('NextCRM form deleted. Form ID: ' . $form_id);

    // Example: delete related custom logs
}

Developer Use Cases

Use this hook to:

// Delete custom form logs
// Remove external form mapping
// Clear cached embed data
// Remove analytics connected to this form

nextcrm/form/deactivate

Runs after a form status is changed.

In your code, this hook fires when the form status is toggled between:

active
deactive

Code Ref

do_action('nextcrm/form/deactivate', $form_id, $new_status);

Parameters

ParameterTypeDescription
$form_idintForm ID.
$new_statusstringNew form status. Example: active or deactive.

Example Usage

add_action('nextcrm/form/deactivate', 'my_nextcrm_form_status_changed', 10, 2);

function my_nextcrm_form_status_changed($form_id, $new_status) {
    if ($new_status === 'deactive') {
        error_log('Form deactivated. ID: ' . $form_id);
    }

    if ($new_status === 'active') {
        error_log('Form activated. ID: ' . $form_id);
    }
}

Developer Use Cases

Use this hook to:

// Disable third-party embed tracking
// Pause related automation
// Clear active form cache
// Notify admin when form is disabled

nextcrm/form/per_page

Controls the fallback form list pagination limit.

Code Ref

$per_page = ($per_page == 0) ? apply_filters('nextcrm/form/per_page', 10000) : $per_page;

Parameters

ParameterTypeDescription
$per_pageintDefault fallback limit. Default value is 10000.

Return

int

Example Usage

add_filter('nextcrm/form/per_page', 'my_nextcrm_form_per_page_limit');

function my_nextcrm_form_per_page_limit($per_page) {
    return 500;
}

Important Code Note

In the current file, this filter may not run because $per_page is already forced to a minimum 1 before this line:

$per_page = max(1, intval($_GET['per_page'] ?? 10));

So per_page can never be 0.

Better format:

$per_page = intval($_GET['per_page'] ?? 10);
$per_page = ($per_page == 0) ? apply_filters('nextcrm/form/per_page', 10000) : max(1, $per_page);

nextcrm/forms/status

Allows developers to modify form status labels.

Code Ref

$this->all_status = apply_filters('nextcrm/forms/status', [
    'active' => esc_html__('Active', 'nextcrm'),
    'deactive' => esc_html__('Deactive', 'nextcrm'),
    'delete' => esc_html__('Delete', 'nextcrm'),
]);

Parameters

ParameterTypeDescription
$statusesarrayStatus key/value label list.

Return

array

Example Usage

add_filter('nextcrm/forms/status', 'my_nextcrm_custom_form_status_labels');

function my_nextcrm_custom_form_status_labels($statuses) {
    $statuses['active'] = 'Published';
    $statuses['deactive'] = 'Paused';
    $statuses['delete'] = 'Deleted';

    return $statuses;
}

Developer Use Cases

Use this hook to:

// Rename status labels
// Add custom status labels
// Translate status names differently
// Match white-label dashboard wording

nextcrm_form_submit

Runs after a form is submitted through the NextCRM Form REST API.

This is the most important frontend form submission hook in this file.

Code Ref

do_action('nextcrm_form_submit', $data, $form);

Parameters

ParameterTypeDescription
$dataarraySubmitted form data plus NextCRM form metadata.
$formobjectForm database row object.

Data Added Before Hook Runs

Before this hook fires, your code adds these values into $data:

$data['list'] = $list;
$data['tags'] = $tags;
$data['contact_status'] = $contact_status;
$data['contact_type'] = $contact_type;
$data['form_type'] = 'form';
$data['form_name'] = $form->title;
$data['form_id'] = $form->id;
$data['ip'] = $ip;

Example Usage

add_action('nextcrm_form_submit', 'my_after_nextcrm_form_submit', 10, 2);

function my_after_nextcrm_form_submit($data, $form) {
    $email = $data['email'] ?? '';

    if (empty($email)) {
        return;
    }

    error_log('New form submission from: ' . $email);
    error_log('Form name: ' . $form->title);
}

Example: Create Contact After Form Submit

add_action('nextcrm_form_submit', 'my_create_contact_from_nextcrm_form', 10, 2);

function my_create_contact_from_nextcrm_form($data, $form) {
    $email = $data['email'] ?? '';

    if (empty($email)) {
        return;
    }

    // Example only. Use your existing NextCRM contact create method if available.
    $existing_contact = nextcrm_manager()->contact->get_contact_by_email($email);

    if ($existing_contact) {
        return;
    }

    // You can call your own contact creation logic here.
}

Example: Trigger Automation After Form Submit

add_action('nextcrm_form_submit', 'my_trigger_automation_after_form_submit', 10, 2);

function my_trigger_automation_after_form_submit($data, $form) {
    if (($data['form_id'] ?? 0) <= 0) {
        return;
    }

    // Example: start custom automation
    do_action('my_custom_form_automation_start', $data, $form);
}

Developer Use Cases

Use this hook to:

// Create or update contact
// Add submitted user to list
// Add tags after form submit
// Trigger automation
// Send webhook
// Save custom submission log
// Notify admin
// Connect external CRM

Full Hook List

// Form lifecycle hooks
nextcrm/form/create
nextcrm/form/update
nextcrm/form/delete
nextcrm/form/deactivate

// Form list filters
nextcrm/form/per_page
nextcrm/forms/status

// Form submission hook
nextcrm_form_submit

Best Developer Example

This is the best example to show in your docs because it connects a real form submission with a custom workflow.

/**
 * Run custom logic after a NextCRM form is submitted.
 */
add_action('nextcrm_form_submit', 'my_nextcrm_after_form_submit', 10, 2);

function my_nextcrm_after_form_submit($data, $form) {
    $email = $data['email'] ?? '';

    if (empty($email)) {
        return;
    }

    // Get useful form data
    $form_id   = $data['form_id'] ?? 0;
    $form_name = $data['form_name'] ?? '';
    $lists     = $data['list'] ?? [];
    $tags      = $data['tags'] ?? [];

    // Example custom log
    error_log('NextCRM form submitted.');
    error_log('Email: ' . $email);
    error_log('Form: ' . $form_name);

    // Example: trigger your own custom process
    do_action('my_custom_nextcrm_form_workflow', $data, $form);
}

Small Improvement Suggestion

Your form submission hook name is:

nextcrm_form_submit

But other hooks use this format:

nextcrm/form/create
nextcrm/form/update
nextcrm/form/delete

For consistency, you can also add an alias without breaking the old hook:

do_action('nextcrm_form_submit', $data, $form);

Next

Leave a Reply

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