Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active April 12, 2024 11:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/2cc8898e1d6b04a85d8fb30058a0734a to your computer and use it in GitHub Desktop.
Save KaineLabs/2cc8898e1d6b04a85d8fb30058a0734a to your computer and use it in GitHub Desktop.
Create Custom Groups Tab
<?php
/**
* Create Custom Groups Tab
*/
add_action( 'bp_actions', 'yzc_create_custom_group_tab' );
function yzc_create_custom_group_tab() {
if ( bp_is_active( 'groups' ) && bp_is_groups_component() && bp_is_single_item() ) {
global $bp;
// Get Current Group.
$current_group = $bp->groups->current_group;
// Add New Group Tab.
bp_core_new_subnav_item(
array(
'position' => 12,
'slug' => 'custom-tab',
'name' => __( 'Custom Tab', 'youzify' ),
'parent_slug' => $current_group->slug,
'parent_url' => bp_get_group_permalink( $current_group ),
'screen_function' => 'yzc_custom_group_tab',
), 'groups'
);
}
}
/**
* Custom Group Tab Content
*/
function yzc_custom_group_tab_content() {
echo 'test';
}
/**
* Custom Group Tab Content
*/
function yzc_custom_group_tab() {
// Call Tab Content.
add_action( 'bp_template_content', 'yzc_custom_group_tab_content' );
// Load Tab Template
bp_core_load_template( 'buddypress/groups/single/plugins' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment