This topic has 4 replies, 3 voices, and was last updated 8 years by Radu.

  • Author
  • #171600
     ahodhellysar
    Participant

    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;

    }

    #171698
     Laura
    Moderator
    Not marked as solution
    #171750
     Radu
    Moderator
    Not marked as solution
    #171760
     ahodhellysar
    Participant
    Not marked as solution
    #171941
     Radu
    Moderator
    Not marked as solution
Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?