Activity

  • Tobias started the question 'theme_location' of "BuddyPanel"? in the forum Boss. theme 8 years, 5 months ago

    Hi,

    I’m trying to add a custom BP menu item to the left-panel (BuddyPanel).
    The BP-item already exists and is working fine.

    To add this menu link to BuddyPanel I found this:

    // Filter wp_nav_menu() to add collections link
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_collections_link' );
    function my_nav_menu_collections_link($menu) {
    if (!is_user_logged_in())
    return $menu;
    else
    $profilelink = '<li><a class="fa fa-bookmark" href="' . bp_loggedin_user_domain( '/' ) . 'my-collections' . '">' . __('Collections') . '</a><div class="sub-menu-wrap"><a href="' . bp_loggedin_user_domain( '/' ) . 'my-collections' . '" class="fa-bookmark">' . __('Collections') . '</a></div></li>';
    $menu = $menu . $profilelink;
    return $menu;
    }

    But than the item also shows in another custom menu I made.
    So I found out to point to a specific location; theme_location probably.

    So I found this:
    // Filter wp_nav_menu() to add profile link in a specific custom menu e.g. mamamia
    function mme_nav_menu_profile_link($menu, $args) {
    if( is_user_logged_in() && $args->theme_location == 'mamamia' ){
    $profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('My Profile', 'yourtheme') . '</a></li>';
    $menu = $menu . $profilelink;
    }
    return $menu;
    }
    add_filter( 'wp_nav_menu_items', 'mme_nav_menu_profile_link', 10, 2 );

    But nothing is showing up by trying to replace theme_location == 'mamamia' with ‘BuddyPanel’ or ‘left-panel’.