Skip to content
View as Markdown

Contact Profile Section ​

FluentCRM Core Intermediate

You can add custom tabs to the FluentCRM contact profile page using the Extender API. This is useful for displaying plugin-specific data alongside contact information.

Basic Example ​

php
add_action('fluent_crm/after_init', function () {
    FluentCrmApi('extender')->addProfileSection(
        'my_custom_section',
        __('My Custom Section', 'your-plugin'),
        function ($contentArr, $subscriber) {
            $contentArr['heading'] = 'Course Progress';
            $contentArr['content_html'] = '<div>
                <p>Email: ' . esc_html($subscriber->email) . '</p>
                <p>Courses completed: 3</p>
            </div>';
            return $contentArr;
        }
    );
});

API Reference ​

FluentCrmApi('extender')->addProfileSection($key, $sectionTitle, $callback, $saveCallback) ​

ParameterTypeRequiredDescription
$keyStringYesUnique section identifier. Use your plugin prefix to avoid conflicts.
$sectionTitleStringYesTab title displayed in the profile sidebar
$callbackCallableYesRenders the section content
$saveCallbackCallableNoHandles save requests from the section

Render Callback ​

The render callback receives two arguments and must return the modified $contentArr:

ParameterTypeDescription
$contentArrArrayContains heading and content_html keys to populate
$subscriberSubscriberThe contact model with all properties and relations

The $contentArr you return must include:

  • heading — Section heading displayed at the top
  • content_html — HTML content rendered in the section body

Save Callback (Optional) ​

If provided, the save callback handles POST requests from your section (e.g., form submissions):

ParameterTypeDescription
$responseArrayResponse array to return
$dataArrayPosted form data
$subscriberSubscriberThe contact model
php
FluentCrmApi('extender')->addProfileSection(
    'my_editable_section',
    __('My Section', 'your-plugin'),
    function ($contentArr, $subscriber) {
        $notes = get_user_meta($subscriber->user_id, 'my_plugin_notes', true);
        $contentArr['heading'] = 'My Plugin Notes';
        $contentArr['content_html'] = '<textarea name="notes">' . esc_textarea($notes) . '</textarea>';
        return $contentArr;
    },
    function ($response, $data, $subscriber) {
        if (isset($data['notes'])) {
            update_user_meta($subscriber->user_id, 'my_plugin_notes', sanitize_textarea_field($data['notes']));
        }
        $response['message'] = __('Notes saved successfully', 'your-plugin');
        return $response;
    }
);

Available Subscriber Properties ​

The $subscriber model provides access to all contact data:

  • $subscriber->email — Contact email
  • $subscriber->first_name, $subscriber->last_name — Name fields
  • $subscriber->status — Contact status (subscribed, pending, etc.)
  • $subscriber->user_id — Linked WordPress user ID (if any)
  • $subscriber->tags — Collection of assigned tags
  • $subscriber->lists — Collection of assigned lists
  • $subscriber->custom_fields() — Custom field values

Custom Contact Profile Section

Source: app/Api/Classes/Extender.php