Add "My Profile" link to main nav
-
Hello,
I’d like to add a “My Profile” link to the buddypress main nav that allows users to link directly to their user profile.
We’re running BP 1.9 and WP 3.7.1
I’ve read through several posts here that got me 90% of the way there — I can get a link to appear in the “profile” nav but not in the main nav that you see if you’re looking at the group page. You know, the nav that lists Home, Forum, Members …
I have added the following to bp-custom.php …
<?php
add_action('bp_setup_nav', 'add_myprofile_to_main_nav', 999 );
function add_myprofile_to_main_nav() {
global $bp;
bp_core_new_nav_item(
array(
'name' => 'My Profile',
'slug' => $bp->loggedin_user->domain,
'position' => 50,
'show_for_displayed_user' => false,
));
}
?>
What do I need to do differently to get it to appear in the main nav for the groups pages instead of the profile nav? Should I be taking a totally different approach?
-
With the latest BuddyPress, you can simply add the My Profile link directly from the menu in your admin CP. Or am I reading what you want incorrectly?
Tecca, thanks for jumping in here … it could be that I’m totally out to lunch, but I’ve been through the back end settings several times looking for a way to customize the BP menus (not the WP menus) … Here’s a screenshot of where I want to add a “my profile” link.
Now, if there’s a way to make WP manage that BP menu for me … I’m dying to learn how to do it. I had simply assumed it would need to be with custom code.
I’m still stuck here … any help would be appreciated. Thanks!
Same question ! I dind’t find any response
Please submit a screenshot of WP-Dashboard -> Appearance -> Menus, BP Items should be in there.
In BP 1.9, you should have this in your WP backend:
All you need to do is select “Profile” and add it to your navigation.
Thanks for jumping in to help … I think I must be doing a poor job, though, of explaining what I’m trying to do …
You are all correct, in WP >> Appearance >> Menus, I see all the BP items … just like in mdpane’s screenshot.
BUT
If I select Profile and “Add to Menu” it goes into my WP custom menus. My site navigation (main nav, sidebar nav, etc.) … but that’s not where I want it.
I want it in the groups menu that appears just above forums …
I’m having trouble getting the image to load … it’s here … http://imgur.com/MFqXlPG
Now, I’ll be the first to admit that you guys could be totally right, and that I’m missing something … but I don’t see a way to use the WP >> appearance >> menu functionality to add links to the GROUPS menu managed by BP.
Thanks again!
BuddyPress doesn’t have a very straightforward way to add links like this to the Groups menu. By design, the links in the group nav are intended to correspond to sub-pages of the Group (which are created by
BP_Group_Extension
), rather than arbitrary external links.That said, while we don’t have a very elegant way of making this happen, you could rig something up to directly insert the link data into the navigation array, just before it gets printed to the screen. Something like this:
function bbg_add_my_profile_to_group_nav() { // Logged-in users only if ( ! is_user_logged_in() ) { return; } // Bail if not looking at a group page if ( ! bp_is_group() ) { return; } buddypress()->bp_options_nav[ bp_get_current_group_slug() ][] = array( 'name' => 'My Profile', 'link' => bp_loggedin_user_domain(), 'slug' => 'my-profile', 'css_id' => 'my-profile', 'position' => 9999999, // make it last 'user_has_access' => true, ); } add_action( 'bp_setup_nav', 'bbg_add_my_profile_to_group_nav', 100 );
Note that you can’t use the function
bp_core_new_subnav_item()
here, because you’re not registering a valid screen callback (among other reasons). Thus the hack of directly inserting the link into the nav.Good luck!
If you don’t see Buddypress in Dashboard > Appearance > Menus make sure you check your Screen Options at the top of the page.
@westdael Thank you! The simple answer that I have been searching for!!
- The topic ‘Add "My Profile" link to main nav’ is closed to new replies.