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:

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.