hello ,
i need to add a dynamic link to menu items , i have already created it usingĀ ‘wp_nav_menu_items’ filter , but now the link appear in all menu locations .. primary and secondary menus, and i can’t control the item (show-hide) based on the user role (i’m using a plugin called “if” for this function) .
what i need is to add this menu item in from the dashboard-menu , so i can control it , show it under sub-menu , show-hide it based the role
the code used to show the link :
add_filter( ‘wp_nav_menu_items’, ‘my_nav_menu_group_link’ );
function my_nav_menu_group_link($menu) {
if (!is_user_logged_in())
return $menu;
else
$my_group_ids = BP_Groups_Member::get_is_admin_of( get_current_user_id() );
foreach( $my_group_ids[‘groups’] as $group ) {
$link = bp_get_group_permalink( $group );
$grouplink = ‘<li><a href=”‘ . $link .( ‘/’ ) . ‘”>’ . __(‘Group’) . ‘</a></li>’;
$menu = $menu . $grouplink;
}
return $menu;
}