Below is the hook documentation based on your uploaded contact hook. I separated them into admin hooks, AJAX hooks, custom action hooks, and custom filter hooks. Code line references are based on the uploaded file.
1. Custom Action Hooks
These are the main developer-facing hooks in your Contact module.
nextcrm/contact/meta/update
Runs before an existing contact meta value is updated.
Code Reference
do_action('nextcrm/contact/meta/update', $contact_id, $meta_key, $meta_value, $old_meta_value);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$meta_key | string | Meta key being updated. |
$meta_value | mixed/string | New meta value. In current code, this is already passed through maybe_serialize(). |
$old_meta_value | mixed | Previous meta value. |
Example
add_action('nextcrm/contact/meta/update', 'my_contact_meta_update_log', 10, 4);
function my_contact_meta_update_log($contact_id, $meta_key, $meta_value, $old_meta_value) {
error_log("Contact {$contact_id} meta {$meta_key} updated.");
}
nextcrm/contact/meta/add
Runs before new contact meta is inserted.
Code Reference
do_action('nextcrm/contact/meta/add', $contact_id, $meta_key, $meta_value);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$meta_key | string | Meta key. |
$meta_value | mixed/string | Meta value. In current code, this may be serialized. |
Example
add_action('nextcrm/contact/meta/add', 'my_contact_meta_add_action', 10, 3);
function my_contact_meta_add_action($contact_id, $meta_key, $meta_value) {
error_log("New meta added for contact {$contact_id}: {$meta_key}");
}
nextcrm/contact/meta/delete
Runs before a contact meta value is deleted.
Code Reference
do_action('nextcrm/contact/meta/delete', $contact_id, $meta_key, $old_meta_value);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$meta_key | string | Meta key being deleted. |
$old_meta_value | mixed | Existing meta value before deletion. |
Example
add_action('nextcrm/contact/meta/delete', 'my_contact_meta_delete_action', 10, 3);
function my_contact_meta_delete_action($contact_id, $meta_key, $old_meta_value) {
error_log("Meta {$meta_key} deleted from contact {$contact_id}");
}
nextcrm/contact/update
Runs after an existing contact is updated successfully.
Code Reference
do_action('nextcrm/contact/update', $contact_id);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Updated contact ID. |
Example
add_action('nextcrm/contact/update', 'my_after_contact_update', 10, 1);
function my_after_contact_update($contact_id) {
$contact = nextcrm_manager()->contact->get_contact_by_id($contact_id);
if ($contact) {
error_log('Contact updated: ' . $contact['email_address']);
}
}
nextcrm/contact/create
Runs after a new contact is created successfully.
Code Reference
do_action('nextcrm/contact/create', $contact_id);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Newly created contact ID. |
Example
add_action('nextcrm/contact/create', 'my_after_contact_create', 10, 1);
function my_after_contact_create($contact_id) {
nextcrm_manager()->contact->set_contact_meta($contact_id, 'welcome_flow_started', 'yes');
}
nextcrm/contact/delete
Runs after a contact is deleted.
Code Reference
Single delete:
do_action('nextcrm/contact/delete', $contact_id);
Bulk delete:
do_action('nextcrm/contact/delete', $contact_id);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Deleted contact ID. |
Example
add_action('nextcrm/contact/delete', 'my_after_contact_delete', 10, 1);
function my_after_contact_delete($contact_id) {
error_log("Contact deleted: {$contact_id}");
}
nextcrm/contact/status/update
Runs after a contact status is updated.
Code Reference
do_action('nextcrm/contact/status/update', $contact_id, $new_status, $old_status);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$new_status | string | New contact status. |
$old_status | string | Previous contact status. |
Example
add_action('nextcrm/contact/status/update', 'my_contact_status_changed', 10, 3);
function my_contact_status_changed($contact_id, $new_status, $old_status) {
if ($new_status === 'unsubscribed') {
error_log("Contact {$contact_id} unsubscribed.");
}
}
nextcrm/contact/tags/add
Runs when a tag is added to a contact.
Code Reference
do_action('nextcrm/contact/tags/add', $contact_id, $tag->name, $tags);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$tag_name | string | Added tag name. |
$tags | array | Final tag list after adding the tag. |
Example
add_action('nextcrm/contact/tags/add', 'my_after_tag_added_to_contact', 10, 3);
function my_after_tag_added_to_contact($contact_id, $tag_name, $tags) {
if ($tag_name === 'vip') {
nextcrm_manager()->contact->set_contact_meta($contact_id, 'vip_added_at', current_time('mysql'));
}
}
nextcrm/contact/tags/remove
Runs when a tag is removed from a contact.
Code Reference
do_action('nextcrm/contact/tags/remove', $contact_id, $tag->name, $tags);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$tag_name | string | Removed tag name. |
$tags | array | Final tag list after removing the tag. |
Example
add_action('nextcrm/contact/tags/remove', 'my_after_tag_removed_from_contact', 10, 3);
function my_after_tag_removed_from_contact($contact_id, $tag_name, $tags) {
error_log("Tag {$tag_name} removed from contact {$contact_id}");
}
nextcrm/contact/list/add
Runs when a list is added to a contact.
Code Reference
do_action('nextcrm/contact/list/add', $contact_id, $list->name, $lists);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$list_name | string | Added list name. |
$lists | array | Final list array after adding the list. |
Example
add_action('nextcrm/contact/list/add', 'my_after_list_added_to_contact', 10, 3);
function my_after_list_added_to_contact($contact_id, $list_name, $lists) {
error_log("Contact {$contact_id} added to list {$list_name}");
}
nextcrm/contact/list/remove
Runs when a list is removed from a contact.
Code Reference
do_action('nextcrm/contact/list/remove', $contact_id, $list->name, $lists);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$list_name | string | Removed list name. |
$lists | array | Final list array after removing the list. |
Example
add_action('nextcrm/contact/list/remove', 'my_after_list_removed_from_contact', 10, 3);
function my_after_list_removed_from_contact($contact_id, $list_name, $lists) {
error_log("Contact {$contact_id} removed from list {$list_name}");
}
nextcrm/contact/field/update
Runs after a standard contact field is updated using update_contact_field().
Code Reference
do_action('nextcrm/contact/field/update', $contact_id, $field, $value, $old_value);
Parameters
| Parameter | Type | Description |
|---|---|---|
$contact_id | int | Contact ID. |
$field | string | Updated field name. |
$value | mixed | New field value. |
$old_value | mixed | Previous field value. |
Example
add_action('nextcrm/contact/field/update', 'my_after_contact_field_update', 10, 4);
function my_after_contact_field_update($contact_id, $field, $value, $old_value) {
if ($field === 'rating') {
error_log("Contact {$contact_id} rating changed from {$old_value} to {$value}");
}
}
Important Note
In your current code, if the field is an additional field like:
additional|mobile
The method returns before this hook runs. So nextcrm/contact/field/update Currently fires only for normal fields, not additional sub-fields.
2. Custom Filter Hooks
These hooks allow developers to modify contact query behavior and AJAX response data.
nextcrm/contact/per_page
Controls the fallback contact limit when per_page it is 0.
Code Reference
$per_page = ($per_page == 0) ? apply_filters('nextcrm/contact/per_page', 10000) : $per_page;
Parameters
| Parameter | Type | Description |
|---|---|---|
$per_page | int | Default fallback contact limit. Default is 10000. |
Return
int
Example
add_filter('nextcrm/contact/per_page', 'my_nextcrm_contact_per_page');
function my_nextcrm_contact_per_page($per_page) {
return 500;
}
nextcrm/contact/ajax/where
Allows developers to add or modify SQL WHERE conditions for the contact AJAX query.
Code Reference
$where_conditions = apply_filters('nextcrm/contact/ajax/where', $where_conditions);
Parameters
| Parameter | Type | Description |
|---|---|---|
$where_conditions | array | SQL WHERE condition parts. |
Return
array
Example
add_filter('nextcrm/contact/ajax/where', 'my_nextcrm_contact_where');
function my_nextcrm_contact_where($where_conditions) {
$where_conditions[] = "rating >= %d";
return $where_conditions;
}
nextcrm/contact/ajax/values
Allows developers to add SQL placeholder values for custom WHERE conditions.
Code Reference
$where_values = apply_filters('nextcrm/contact/ajax/values', $where_values);
Parameters
| Parameter | Type | Description |
|---|---|---|
$where_values | array | SQL values used in $wpdb->prepare(). |
Return
array
Example
Use this together with nextcrm/contact/ajax/where.
add_filter('nextcrm/contact/ajax/where', function($where_conditions) {
$where_conditions[] = "rating >= %d";
return $where_conditions;
});
add_filter('nextcrm/contact/ajax/values', function($where_values) {
$where_values[] = 4;
return $where_values;
});
nextcrm/contact/ajax/response
Allows developers to modify the final contact AJAX response before it is returned.
Code Reference
$response_data = apply_filters('nextcrm/contact/ajax/response', array(
'contacts' => $contacts,
'pagination' => array(
'total' => intval($total_contacts),
'per_page' => $per_page,
'current_page' => $page,
'total_pages' => ceil($total_contacts / $per_page)
),
'display_columns' => $display_columns,
'enable_quick_overview' => $enable_quick_overview,
'quick_overview_position' => $quick_overview_position,
));
Parameters
| Parameter | Type | Description |
|---|---|---|
$response_data | array | Final contact list response data. |
Return
array
Example
add_filter('nextcrm/contact/ajax/response', 'my_nextcrm_contact_ajax_response');
function my_nextcrm_contact_ajax_response($response_data) {
$response_data['custom_message'] = 'Modified by custom plugin';
return $response_data;
}
3. Full Hook List Summary
Action Hooks
nextcrm/admin_menu/bottom
nextcrm/admin/enqueue/middle
nextcrm/contact/meta/update
nextcrm/contact/meta/add
nextcrm/contact/meta/delete
nextcrm/contact/update
nextcrm/contact/create
nextcrm/contact/delete
nextcrm/contact/status/update
nextcrm/contact/tags/add
nextcrm/contact/tags/remove
nextcrm/contact/list/add
nextcrm/contact/list/remove
nextcrm/contact/field/update
Filter Hooks
nextcrm/enqueue/admin/page/dependency
nextcrm/admin/notices/dependency
nextcrm/enqueue/admin/dependency
nextcrm/contact/per_page
nextcrm/contact/ajax/where
nextcrm/contact/ajax/values
nextcrm/contact/ajax/response