Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show user's option nav in sidebar globally

  • @maxaud

    Participant

    I’d like to show the users component nav ($bp->bp_nav) and the option nav ($bp->bp_options_nav) in the sidebar at all times.

    The problem I’m seeing is that when viewing another users profile, this nav is populated for the other user.

    How do I go about getting the navigation always for the current logged in user?

    Thank you for any help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • @chouf1

    Participant

    i guess you have to get the logged-in user ID

    $bp->loggedin_user->id

    https://codex.buddypress.org/developer/developer-docs/the-bp-global/

     

    @maxaud

    Participant

    That doc states that $bp->nav is for the currently logged in user but that is incorrect. The counts for projects, groups, etc is for the currently displayed user.

    The $bp->bp_options_nav is still being generated for the currently viewed user. How can I generate a similar list for the currently logged in user?

    @chouf1

    Participant

    BP version ? And theme name ?
    Have you already a code example you want to use ?

    @maxaud

    Participant

    BuddyPress version 1.6.4

    Theme is homegrown but my needs wouldn’t change depending upon theme being used.

    I’m current looping through the $bp->nav and $bp->bp_option_nav variables to construct the code needed but these variables change whether you’re viewing another users profile or not.

    I need to construct the same menu as if you were viewing your own profile but display it on every page, even if viewing another users profile.

    @chouf1

    Participant

    in other words, you want the old buddybar “My account” menu from the buddybar to the sidebar ?

    take a look in bp-core/bp-core-adminbar.php and bp-core-buddybar.php <- this one is well commented

    you can also revert to the old buddybar by adding this to bp-custom to view the difference with the default WP Toolbar

    add_filter( 'bp_use_wp_admin_bar', '__return_false' ); 

    @maxaud

    Participant

    Thanks, I’ll check it out.

    Much appreciated.

    @maxaud

    Participant

    It seems this just uses str_replace to change the URL on displaying the menu. The blog count is hidden with CSS but shows the displayed user count rather than the logged in user’s blog count (even in the admin bar).

    May have to str_replace the count as well..

    @chouf1

    Participant

    The difficulty of this menu is his ability for contextual output, depending of the component page. It is also a bit complicated to around this because activities are sort by type. In fact much more sophisticated as a simple menu containing simple a. tags

    Happy coding !

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Show user's option nav in sidebar globally’ is closed to new replies.
Skip to toolbar