How to Add Custom Tabs to the User/Lead Profile History Section in CRM

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

FieldTypeDescription
Key (array key)stringUnique tab identifier
`priority`intDisplay order (ascending); lower = first tab
`name`stringTab label shown to the user
`callback`stringFully-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.

Manage Cookies

Choose which cookies this website may use. You can change your choice at any time.

Always on

Required for the website to work, for example to keep you signed in, keep your shopping cart and remember this cookie choice. They cannot be switched off.

Analytics, social media connections, live chat and personalized advertising based on your online activity. These are only used if you allow them.