Making Profile the default landing page in BuddyPress
Dec 21, 2010 at 11:04 pm in Advanced Tutorials, BuddyPress by Michael Eisenwasser (Admin) ·
If you have Activity enabled on your BuddyPress site, you will notice that Activity is the default landing page for user profiles. However for many sites it makes more sense to keep the public Profile page as the user landing page. It’s actually pretty simple to implement. We just need to reorder the tabs so Profile comes before Activity, and set Profile as the default tab.
If you don’t have one already, create a file in your plugins folder called bp-custom.php. Don’t forget, this file must open with .
Reorder the tabs so Profile comes before Activity
Just add this code to bp-custom.php:
[php]
/* Reorder profile tabs */
function bbg_change_profile_tab_order() {
global $bp;
$bp->bp_nav['profile']['position'] = 10;
$bp->bp_nav['activity']['position'] = 20;
}
add_action( ‘bp_setup_nav’, ‘bbg_change_profile_tab_order’, 999 );
[/php]
You can add other nav items using this same format, and simply order them by increments of 10. Other options include:
[php]
$bp->bp_nav['blogs']['position'] = 30;
$bp->bp_nav['friends']['position'] = 40;
$bp->bp_nav['messages']['position'] = 50;
$bp->bp_nav['groups']['position'] = 60;
$bp->bp_nav['settings']['position'] = 70;
[/php]
Set Profile as the default tab
Just add this code to bp-custom.php
[php]
/* define the default Profile component */
define("BP_DEFAULT_COMPONENT","profile");// Now when you click on a user name link, You will land on User’s profile not user’s activity page
[/php]
Jon said on January 19, 2011
Helpful, to the point, and most importantly it just works. Thanks!
David Payne said on January 27, 2011
Hey Mike (or do you prefer Michael?)
Thanks so much for this tip! It works great. I did notice one small thing that’s happening now and I’m not sure if it’s unique to my site or if it happens elsewhere. When somebody has been “friended” you receive a notification within the admin bar at the top of the page. Upon clicking this it now takes you to the person’s profile, but it does not clear the notification. The only way the notification is cleared is if you visit the Friends section within your profile. Is there an easy fix for that?
Piotr Kaluza said on April 3, 2012
As of 1.5 you don’t have to reorder the tabs.
Just define (BP_DEFAULT_COMPONENT, ‘profile’) in your functions.php
Sangam said on June 20, 2012
thanks alot ,really your help appreciated .
omdev said on July 7, 2012
can any buddy say how to add sub nav tab in profile page next to change avatar link ?
TJ Chester (Admin) said on July 8, 2012
Omdev, you can edit sidebar-home-left.php to add links here.