Hook: on_profile_sidebar_links
avatar
Señor FAQ

¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.


Hook: on_profile_sidebar_links

The on_profile_sidebar_links hook allows developers to dynamically add or modify links displayed in the user profile sidebar. This is particularly useful for integrating custom functionality, such as links to marketplace features, support, or other plugins. This hook needs to be used in combination with the on_profile_tab_content hook.

Usage


$links = [
    [
        'id' => 'profile-basic',
        'href' => $profile,
        'icon' => 'fas fa-user fa-fw me-2',
        'label' => $this->lang['my_profile'],
        'class' => 'active',
        'is_tab' => true
    ]
];

$additionalLinks = DynamicHooks::executeHook('on_profile_sidebar_links', true);
if (!empty($additionalLinks) && is_array($additionalLinks)) {
    $links = array_merge($links, $additionalLinks);
}
    

This hook aggregates custom sidebar links and merges them with default links in the profile sidebar.

Example Implementation


DynamicHooks::addHook('on_profile_sidebar_links', function () use ($jkv, $lang) {
    return [
        [
            'id' => 'mp-support',
            'href' => DynamicRewrite::parseUrl($jkv['slugforsiteprofile'], 'mp-support'),
            'icon' => 'fas fa-life-ring fa-fw me-2',
            'label' => $lang['marketplace_profile_support'],
            'class' => '',
            'is_tab' => true
        ],
        [
            'id' => 'mp-purchases',
            'href' => DynamicRewrite::parseUrl($jkv['slugforsiteprofile'], 'mp-purchases'),
            'icon' => 'fas fa-shopping-bag fa-fw me-2',
            'label' => $lang['marketplace_profile_purchase'],
            'class' => '',
            'is_tab' => true
        ]
    ];
}, 'your_plugin');
    

Best Practices

  • Ensure each link has a unique id to avoid conflicts.
  • Use descriptive icons and labels for a better user experience.
  • Verify that all links point to valid and accessible URLs.

Troubleshooting

  • Check for missing or incorrect link properties (e.g., href, label).
  • Ensure the hook is registered with the correct namespace and returns an array of links.
  • Debug using browser developer tools to inspect the rendered sidebar and links.
Was this article helpful?
0 out of 0 found this helpful