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/page in the groups page.

This is the code I'm using:

<?php
/*
Plugin Name: Groups Links
Description: Add links to the groups page.
Author: Thomas Clayson
*/
function add_groups_links_page(){
    global $bp;

    $groups_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';

    bp_core_new_subnav_item( array(
       'name' => 'Links',
       'slug' => 'group-links',
       'parent_url' => $groups_link,
       'parent_slug' => $bp->groups->slug,
       'screen_function' => 'group_links_function_to_show_screen',
       'position' => 40 ) );
}
add_action( 'wp', 'add_groups_links_page');

function group_links_function_to_show_screen() {

    add_action( 'bp_template_title', 'group_links_function_to_show_screen_title' );
    add_action( 'bp_template_content', 'group_links_function_to_show_screen_content' );

    $templates = array('groups/single/plugins.php','plugin-template.php');
    if( strstr( locate_template($templates), 'groups/single/plugins.php' ) ) {
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'groups/single/plugins' ) );
    } else {
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
    }
}

function group_links_function_to_show_screen_title() {
    echo 'Links';
}

function group_links_function_to_show_screen_content() { 
    echo "Rawr";
}


?>

Yet when I click on "Links" on the groups page it just takes me back to the homepage! :( I have no idea why this isn't working. Here is a screenshot of the page:

enter image description here

In the picture I've mouse-over'd the link and you can see that it points to the right place... wordpressdomain/groups/test-group/group-links/ however clicking it takes me to the homepage! :(

Any ideas?

Thank you.

share|improve this question
    
Let me know if you find an answer to this. This has been driving me nuts all day! –  Brian Fegter Apr 20 '11 at 15:30
    
nothing yet... :( –  Thomas Clayson Apr 21 '11 at 15:09

1 Answer 1

instead of this:

'slug' => 'group-links',
'parent_url' => $groups_link,

Use this:

'parent_slug' => $bp->groups->current_group->slug, 
'parent_url' => bp_get_group_permalink( $bp->groups->current_group ), 
share|improve this answer

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.