How to Add Custom Action Buttons to the Profile Page Toolbar

How to add custom action buttons to the profile page header toolbar.


Overview

The `la24_render_profile_action_btn` filter lets extensions inject custom HTML buttons into the toolbar at the top of the user/lead profile page. Buttons can link to custom CRM pages, trigger modals, or perform any front-end action.

Hook Signature

php
apply_filters( 'la24_render_profile_action_btn', array $actions, bool $is_clue );
**Type:** Filter **Parameters:**
  • `$actions` (array) — current button registry
  • `$is_clue` (bool) — `true` when the profile belongs to a Lead; `false` for a registered User
**Returns:** array

Adding a Profile Action Button

php
add_filter( 'la24_render_profile_action_btn', function ( $actions, $is_clue ) {

    $profile_id = (int) ( $_GET['id'] ?? 0 );

    // Only add button for users (not leads)
    if ( ! $is_clue && la24_user_can( get_current_user_id(), 'my_crm_view_reports' ) ) {
        $report_url = la24_get_permalink_panel( 'MyCrmReports/?user_id=' . $profile_id );

        $actions['my_crm_report_btn']['content'] =
            "<a href='" . esc_url( $report_url ) . "' class='btn btn-sm btn-outline-primary'>
                <i class='fa fa-bar-chart'></i> " . esc_html__( 'View Report', 'my-crm-ext' ) . "
            </a>";
    }

    return $actions;

}, 10, 2 );
> Note the `10, 2` at the end of `add_filter` — the third argument is the priority and the fourth (`2`) tells WordPress this callback accepts 2 parameters.

Action Fields

Each entry in `$actions` is keyed by a unique identifier. The value must contain a `content` key with the raw HTML to render:
php
$actions['my_unique_btn_key'] = array(
    'content' => '<a href="..." class="btn btn-sm">...</a>',
);
Use Bootstrap button classes (already loaded in the CRM panel) for visual consistency:
ClassAppearance
`btn btn-sm btn-outline-primary`Blue outline button
`btn btn-sm btn-outline-success`Green outline button
`btn btn-sm btn-outline-danger`Red outline button
`btn btn-sm btn-primary`Filled blue button

Distinguishing Users from Leads

php
if ( $is_clue ) {
    // This profile is a Lead (unregistered contact)
} else {
    // This profile is a registered WordPress User
}
Use this flag to conditionally show buttons that only apply to one type of profile.

Building the Button URL

php
$profile_id = (int) ( $_GET['id'] ?? 0 );
$url = la24_get_permalink_panel( 'MyEndpoint/?user_id=' . $profile_id );
Always escape the URL when outputting to HTML:
php
echo esc_url( $url );

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.