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 am having issues with getting the Wordpress as well as Buddypress to load with a custom profile tab.

I originally got the template, "game.php" to load, but the page is not loading into the profile item-body area as with other navigation tabs as well as plugins. Instead it loaded onto a blank page with nothing but that template's content.

function my_setup_nav() {
    global $bp;
    bp_core_new_nav_item(
        array( 
            'name' => __('Games', 'buddypress'), 
            'slug' => 'games', 
            'position' => 100, 
            'show_for_displayed_user' => true, 
            'screen_function' => 'profile_games_page', 
            'item_css_id' => $bp->games->id 
    ));
}

add_action( 'bp_setup_nav', 'my_setup_nav', 100 );

Original coding of trouble area...

function profile_games_page() {
    bp_core_load_template( apply_filters( 'bp_core_template', 'games' ) );
}

In searching I found this which I believe lead me on the right direction. Now it shows in the content area. But none of the sidebars and footers are present. Is it possible there is an add_action I am missing to include those?

function profile_games_page() {
    add_action( 'bp_template_content_header', 'bp_plugin_menu_header' );
    add_action( 'bp_template_content', 'profile_games_content' );

    bp_core_load_template( 'members/single/plugins' );
}

function profile_games_content() {
    bp_core_load_template('games');

}

I am sorry that I know so very little about Buddypress and how to get this working, but I really appreciate any help on this. Many searches online resulted in things that I believe were so far above what I am trying to do, that they made little sense. Once again thank you in advance for your help.

Using Wordpress 3.6.1, Buddypress 1.8.1

share|improve this question
    
I did figure this out. But it seems I must wait a few hours to answer my own question to help anyone else who comes across this. I will be doing so when I am able. –  Pelligea Oct 15 '13 at 23:11
add comment

1 Answer

After a lot of wasted time researching, I found my silly mistake. But I wanted to answer my own question for anyone else who comes across this issue.

The original block of code is basically correct minus this...

'item_css_id' => $bp->games->id 

Which should have been simply a string of some sort like so.

'item_css_id' => 'game_page'

While that did change the id of the actual button for CSS purposes, it did not cause any of my issues. Instead I called bp_core_load_template() twice. Instead of just the one time and simply putting in my content into the third function. So the final code looks like so.

function my_setup_nav() {
    global $bp;
    bp_core_new_nav_item(
        array( 
            'name' => __('Games', 'buddypress'), 
            'slug' => 'games', 
            'position' => 100, 
            'show_for_displayed_user' => true, 
            'screen_function' => 'profile_games_page', 
            'item_css_id' => 'game-page' 
    ));
}

add_action( 'bp_setup_nav', 'my_setup_nav', 100 );

function profile_games_page() {
    add_action( 'bp_template_content_header', 'bp_plugin_menu_header' );
    add_action( 'bp_template_content', 'profile_games_content' );
    bp_core_load_template( 'members/single/plugins' );
}

function profile_games_content() {
    // The tabs called content goes here
}

I hope I can help someone else looking to attempt the same issues down the line. And should I have still made errors, I would love to know about them. Thanks again for anyone else who took a moment to read this.

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.