How to add a new Member Page to Buddy Press

Platform: BuddyPress

In Buddy Press each directory under the members/single directory is known as a component and can be very frustrating to customize. I recently had to add several new components to a theme and thought I should post the resulting snippet for others looking to modify their theme.

Step 1. Create the directory and the file under the directory you wish to add

Step 2. Add the following code (customized to your specific folder and filename of course) to the functions.php file in your theme.

Basically everywhere I have wishlist, the name of my component, you should add your desired component name

//Loads Custom Component into specified Nav
add_action( 'bp_setup_nav', 'add_subnav_items', 100 ); //Priority must be higher than 10
function add_subnav_items() {
global $bp;

$tab_array['name'] = 'Wishlist';
         $tab_array['link'] = $bp->displayed_user->domain.'wishlist';
         $tab_array['slug'] = 'members/single/wishlist/';
         $tab_array['show_for_displayed_user'] = 1;
         $tab_array['parent_url'] = $bp->displayed_user->domain;
         $tab_array['parent_slug'] = bp_core_get_userlink(bp_loggedin_user_id());
         $tab_array['css_id'] = 'wishlist';
         $tab_array['position'] = 100;
         $tab_array['user_has_access'] = '1';

         $bp->bp_nav['wishlist'] = $tab_array; //Add new array element to the 'bp_nav' array

//Loads Template for new component if that component is selected
define('BP_WISHLIST_SLUG', 'wishlist');
function bp_show_wishlist_page() {
         global $bp, $current_blog;
         if ( $bp->current_component == BP_WISHLIST_SLUG && $bp->current_action == '' ) {
             bp_core_load_template( 'members/single/home', true );

add_action( 'wp', 'bp_show_wishlist_page', 101 );

Step 3.  Modify your members/single/ home.php to look for the new component name and load the desired file.

<pre> $pagename = $bp->current_component

 if ( $pagename === "wishlist" ) :
    locate_template( array( 'members/single/wishlist/wishlist.php' ), true )


The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,