lafif-a
11/25/2014 - 6:03 AM

[Wordpress][Buddypress] Add new menu item buddypress profile

[Wordpress][Buddypress] Add new menu item buddypress profile

<?php 

function custom_bp_nav() {
  global $bp;
  bp_core_new_nav_item(
      array(
          'name'                => __( 'Site Settings', 'buddypress' ),
          'slug'                => 'site-settings',
          'position'            => 80,
          'screen_function'     => 'site_settings_screen',
          'default_subnav_slug' => 'site-settings',
          'parent_url'          => $bp->loggedin_user->domain . $bp->slug . '/',
          'parent_slug'         => $bp->slug
      ) );
}

function site_settings_screen() {
  // bp_core_load_template( 'item-one-template' ); // if just need to load a page template for your custom item. You'll need to have an item-one-template.php in your theme root. or

  //add title and content here - last is to call the members plugin.php template
  add_action( 'bp_template_title', 'site_settings_screen_title' );
  add_action( 'bp_template_content', 'site_settings_screen_content' );
  bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}

function site_settings_screen_title() {
  echo 'Site Settings';
}

function site_settings_screen_content() {
  echo 'Content here';

}

add_action( 'bp_setup_nav', 'custom_bp_nav', 50 );