Skip to content

Instantly share code, notes, and snippets.

@wbcomdev
Created March 31, 2023 07:22
Show Gist options
  • Select an option

  • Save wbcomdev/68bb6820a8d13f64e24525801abe98d0 to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/68bb6820a8d13f64e24525801abe98d0 to your computer and use it in GitHub Desktop.
<?php
function setup_group_nav() {
global $bp;
/* Add some group subnav items */
$user_access = false;
$group_link = '';
if ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) ) {
$group_link = $bp->root_domain . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug . '/';
$user_access = $bp->groups->current_group->user_has_access;
bp_core_new_subnav_item(
array(
'name' => __( 'Custom', 'custom' ),
'slug' => 'custom',
'parent_url' => $group_link,
'parent_slug' => $bp->groups->current_group->slug,
'screen_function' => 'bp_group_custom',
'position' => 50,
'user_has_access' => $user_access,
'item_css_id' => 'custom',
)
);
}
}
add_action( 'bp_setup_nav', 'setup_group_nav' );
function bp_group_custom() {
add_action( 'bp_template_content', 'my_new_group_show_screen_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'groups/single/plugins' ) );
}
function my_new_group_show_screen_content() {
echo do_shortcode( '[bp_group_tab_shortcode type="student"]' );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment