Skip to:
Content
Pages
Categories
Search
Top
Bottom

User’s menu


  • Koka boka
    Participant

    @koka777

    Hello, please tell me how you can show the current user’s menu separately outside his profile (in a separate place on the site, perhaps in the header or footer). Thank you in advance.

Viewing 1 replies (of 1 total)

  • Shah gee
    Participant

    @alishah909

    To display the current user’s menu outside of their profile in BuddyPress, you can use the bp_get_menu function. This function retrieves the menu items for the current user and returns them as an array.

    Here’s an example code snippet that you can use to display the current user’s menu in the header or footer:
    `
    <?php
    $menu_items = bp_get_menu( array( ‘user_id’ => get_current_user_id() ) );
    if ( ! empty( $menu_items ) ) {
    echo ‘<ul>’;
    foreach ( $menu_items as $menu_item ) {
    echo ‘<li><a href=”‘ . $menu_item[‘url’] . ‘”>’ . $menu_item[‘label’] . ‘</a></li>’;
    }
    echo ‘</ul>’;
    }
    ?>
    `
    This code retrieves the menu items for the current user using bp_get_menu, then loops through the array and displays each menu item as a list item.

    You can place this code in your theme’s header or footer file, or in a separate template file, depending on your site’s structure.

    I hope this helps! Let me know if you have any further questions.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar