Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add a new tab to my groups on BuddyPress. All the groups will have different content preferrably from the database.

How can I accomplish this?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

There's an example of this on the buddypress forums which is a good place to start looking for answers.

http://buddypress.org/community/groups/creating-extending/forum/topic/can-someone-explain-how-to-add-tabs-to-the-profile-page/

For the sake of answering here though here goes:

bp_core_new_subnav_item( array(
   'name' => 'My Group Page',
   'slug' => 'my-group-page',
   'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/',
   'parent_slug' => $bp->groups->slug,
   'screen_function' => 'my_groups_page_function_to_show_screen',
   'position' => 40 ) );

And the screen function to render the page:

function my_groups_page_function_to_show_screen() {

    //add title and content here - last is to call the members plugin.php template
    add_action( 'bp_template_title', 'my_groups_page_function_to_show_screen_title' );
    add_action( 'bp_template_content', 'my_groups_page_function_to_show_screen_content' );
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}

    function my_groups_page_function_to_show_screen_title() {
        echo 'My Page Title';
    }
    function my_groups_page_function_to_show_screen_content() { 

        // page content goes here

    }
share|improve this answer
add comment

For your example to work, you need to wrap it in a function like this (that you'll place in functions.php) :

function my_setup_nav() {
    global $bp;
    bp_core_new_subnav_item( array(
       'name' => 'My Group Page',
       'slug' => 'my-group-page',
       'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/',
       'parent_slug' => $bp->groups->slug,
       'screen_function' => 'my_groups_page_function_to_show_screen',
       'position' => 40 ) );
}
add_action( 'bp_setup_nav', 'my_setup_nav' );

and place you rendreing function after obviously.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.