Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: $bp->bp_options_nav wrong user links

@danbp

Participant

@jejemo

try by adding this at the begin of your function
$user_id = bp_get_activity_user_id();

If you’re working on the Toolbar, the correct way to add a menu is like on this example:


/* add links/menus to the admin bar*/
/* more details here: http://wpengineer.com/2113/add-menus-to-the-admin-bar-of-wordpress/ */

function mytheme_admin_bar_render() {
global $wp_admin_bar;

	$wp_admin_bar->add_menu( array(
		'parent' => 'new-content', // use 'false' for a root menu, or pass the ID of the parent menu
		'id' => 'new_media', // link ID, defaults to a sanitized title value
		'title' => __('Media'), // link title
		'href' => admin_url( 'media-new.php') // name of file
		'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
		)
	);
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' ); 

A similar method is used to add a tab. Here on a user profile.

function bpfr_my_setup_nav() {
    global $bp;
	
	$mytab=array(
	'name'            => 'My Tab',
	'link'      	  => 'http://example.com/wp-content/themes/twentythirteen/my_extra_page.php',
	'slug'         	  => 'my-tab',
	'css_id'          => 'my_custom_tab',
	'position'        => 100,
	'user_has_access' => 1,
    'screen_function' => 'xprofile_screen_my_tab'
	);
	$bp->bp_options_nav['profile']['my-tab']=$mytab; 	
}
add_action('bp_setup_nav', 'bpfr_my_setup_nav');
Skip to toolbar