@dayan89,
could it be that you created your Top menu, by adding a new menu without having two different menu location in your theme ? This can explain why you see always your item, what ever menu you choose. This happen because you try to assign 2 different menus to a same place.
Following snippets where successfully tested with Twenty Twelve.
This fires the profile link on the menu tab.
function profile_button_menu_item ( $items, $args ) {
// menu name. Primary is default main menu location in Twenty themes
if ( $args->theme_location == 'primary') {
$items .= '<li><a href="' . bp_loggedin_user_domain() . 'profile/public/">' . __('My Profile') . '</a></li>';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'profile_button_menu_item', 10, 2 );
The following explains how it works with 2012.
In 2012’s header.php, there is only one menu, located line 45
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) );?>
To use 2 menus, I added below that line another location
<?php wp_nav_menu( array( 'theme_location' => 'top', 'menu_class' => 'nav-menu' ) );?>
In child-theme’s functions.php, i added
function register_my_menu() {
register_nav_menus(
array(
'top' => 'Top'
)
);
}
add_action( 'init', 'register_my_menu' );
Under Menu Settings (wp-admin/nav-menus.php) i have now 2 theme locations.
Primary Menu
and Top
Understand here that 2 locations are different of having only 2 menus. Location is a unique place for ONE menu.
Of course, I have 2 different menus. One is assigned to Primary Menu location, the other one to Top location.
And i can now move my profile item from one to other menu, by simply changing the location (primary ⇔ top) in profile_button_menu_item
function.
Codex reference: https://codex.wordpress.org/Navigation_Menus