Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Unable to Add Profile Tab

@danbp

Participant

hello @optiqal,
using snippets from 2012 leads to errors in many case. 😉

Here’s a new version of what you used. I tested it on BP 2.1 and 2013 theme.
(original code comes from here) As it contained errors i corrected them and adjusted the code to get content everywhere.

/* we're building the nav button and add it to the profile main menu */
function mb_bp_profile_menu_posts() {
	global $bp;
	bp_core_new_nav_item(
	array(
	'name' => 'My Posts',
	'slug' => 'posts', 
	'position' => 11, 
	'default_subnav_slug' => 'published', 
	'screen_function' => 'mb_author_posts'
	)
	);
}
add_action('bp_setup_nav', 'mb_bp_profile_menu_posts', 301 );

/* we're building 2 sub item
 * the first is the one showing by default
 */

function mb_bp_profile_submenu_posts() {
	global $bp;
	if(!is_user_logged_in()) return '';
	bp_core_new_subnav_item( array( 
	'name' => 'Published',
	'slug' => 'published', 
	'parent_url' => $bp->loggedin_user->domain . $bp->bp_nav['posts']['slug'] . '/' ,
	'parent_slug' => $bp->bp_nav['posts']['slug'],
	'position' => 10,
	'screen_function' => 'mb_author_posts' //the function is declared below
	) 
	); 
	bp_core_new_subnav_item( array( 
	'name' => 'Drafts',
	'slug' => 'drafts', 
	'parent_url' => $bp->loggedin_user->domain . $bp->bp_nav['posts']['slug'] . '/' ,
	'parent_slug' => $bp->bp_nav['posts']['slug'],
	'position' => 20,
	'screen_function' => 'mb_author_drafts' //the function is declared below
	) 
	); 
}
add_action('bp_setup_nav', 'mb_bp_profile_submenu_posts', 302 );

/* here we control our 1st sub item
 * first function is the screen_function
 * second function displays the content
*/
function mb_author_posts(){	
	add_action( 'bp_template_content', 'mb_show_posts' );
	bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
function mb_show_posts() {
	echo 'Function to Generate the displayed users posts.';
	// add yout stuff here
}

/* here we control our 2nd sub item
 * first function is the screen_function
 * second function displays the content
 */
function mb_author_drafts() {
	add_action( 'bp_template_content', 'mb_show_drafts' );
	bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}
function mb_show_drafts() {
	echo 'Another function to Generate the displayed users drafts.';
	// add yout stuff here
}
Skip to toolbar