Skip to content

Instantly share code, notes, and snippets.

@raviousprime
Created August 28, 2019 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raviousprime/dd4edd6875709c8d4cc9a2b9bf044652 to your computer and use it in GitHub Desktop.
Save raviousprime/dd4edd6875709c8d4cc9a2b9bf044652 to your computer and use it in GitHub Desktop.
Adding custom tab to user profile
<?php
/**
* Display content on tab.
*/
function buddydev_custom_screen_content() {
echo 'hello BuddyDev';
}
/**
* Callback screen function.
*/
function buddydev_custom_screen() {
add_action( 'bp_template_content', 'buddydev_custom_screen_content' );
bp_core_load_template( 'members/single/plugins' );
}
add_action( 'bp_setup_nav', function() {
// Add tab here.
bp_core_new_nav_item(
array(
'name' => __( 'Custom Tab' ),
// Display name for the nav item.
'slug' => 'custom',
// URL slug for the nav item.
'item_css_id' => false,
// The CSS ID to apply to the HTML of the nav item.
'show_for_displayed_user' => true,
// When viewing another user does this nav item show up?
'position' => 99,
// Index of where this nav item should be positioned.
'screen_function' => 'buddydev_custom_screen',
// The name of the function to run when clicked.
'default_subnav_slug' => false,
// The slug of the default subnav item to select when clicked.
)
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment