Show user's option nav in sidebar globally
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!
i guess you have to get the logged-in user ID
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?
BP version ? And theme name ?
Have you already a code example you want to use ?
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.
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
Thanks, I’ll check it out.
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..
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 !
- The topic ‘Show user's option nav in sidebar globally’ is closed to new replies.