Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show user's option nav in sidebar globally


  • Maxaud
    Participant

    @maxaud

    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)

  • danbpfr
    Participant

    @chouf1

    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

    @maxaud

    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?


    danbpfr
    Participant

    @chouf1

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


    Maxaud
    Participant

    @maxaud

    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.


    danbpfr
    Participant

    @chouf1

    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

    @maxaud

    Thanks, I’ll check it out.

    Much appreciated.


    Maxaud
    Participant

    @maxaud

    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..


    danbpfr
    Participant

    @chouf1

    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