How to add custom tabs to the user/lead profile history section in the CRM.
Overview
The `la24_history_user_profile` filter allows extensions to add custom tabs to the **profile history** section that appears on user and lead profile pages. Each tab is rendered by a dedicated controller class.

Hook Signature
php
apply_filters( 'la24_history_user_profile', array $tabs );
**Type:** Filter
**Parameters:** `$tabs` (array) — the current tab registry
**Returns:** array — the modified tab registry
Registering a Profile History Tab
php
add_filter( 'la24_history_user_profile', function ( $tabs ) {
$tabs['my_activity_log'] = array(
'priority' => 10,
'name' => __( 'Activity Log', 'my-crm-ext' ),
'callback' => '\MyPlugin\Controllers\ActivityLogHistory',
);
return $tabs;
} );
Tab Fields
| Field | Type | Description |
|---|---|---|
| Key (array key) | string | Unique tab identifier |
| `priority` | int | Display order (ascending); lower = first tab |
| `name` | string | Tab label shown to the user |
| `callback` | string | Fully-qualified controller class name |
Tab Controller Class
The controller extends `BaseViewController` and implements `content()` to render the tab body:
php
<?php
namespace MyPlugin\Controllers;
use LoyalAxis\abstracts\BaseViewController;
defined( 'ABSPATH' ) || exit;
class ActivityLogHistory extends BaseViewController {
public function content() {
$user_id = (int) ( $_GET['id'] ?? 0 );
if ( ! $user_id ) return;
// Check capability
if ( ! la24_user_can( get_current_user_id(), 'my_crm_view_activity_log' ) ) {
echo '<p>' . esc_html__( 'Access denied.', 'my-crm-ext' ) . '</p>';
return;
}
global $wpdb;
$logs = $wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}my_activity_log WHERE user_id = %d ORDER BY created_at DESC LIMIT 50",
$user_id
)
);
foreach ( $logs as $log ) {
echo '<div class="la24-history-item">';
echo '<span class="date">' . esc_html( $log->created_at ) . '</span>';
echo '<span class="action">' . esc_html( $log->action ) . '</span>';
echo '</div>';
}
}
}

Accessing the Profile User ID
The profile user (or lead) ID is passed via the `id` query parameter:
php
$user_id = (int) ( $_GET['id'] ?? 0 );
if ( ! $user_id ) return; // guard: tab rendered without a valid profile
Always validate the ID before making database queries. Always check the relevant capability before rendering sensitive data.