Skip to:
Content
Pages
Categories
Search
Top
Bottom

Error while navigating to Buddypress Group using custom created Link


  • nickrobinson352
    Participant

    @nickrobinson352

    I created dynamic menus to the Buddy Press groups using the following code

    `$url = site_url().”/groups/”.$groupslug;’

    The $url variable has the correct variable, but while clicking from there, wordpress switches to the intended group, but I get a warning that says –
    “Notice: bp_nav was called incorrectly. These globals should not be used directly and are deprecated. Please use the BuddyPress nav functions instead. Please see Debugging in WordPress for more information. (This message was added in version 2.6.0.) in /home/…/functions.php on line 3897”

    I dont get the same warning when I click through the normal buddpress pages.

Viewing 5 replies - 1 through 5 (of 5 total)

  • r-a-y
    Keymaster

    @r-a-y

    You have some other BuddyPress plugins that is causing this notice.

    For now, I would recommend turning off WP_DEBUG mode on your production site.


    danbp
    Participant

    @danbp

    Can you provide the complete code you use for that and also tell where the menu item goes inside groups ?


    nickrobinson352
    Participant

    @nickrobinson352

    Here is the function where I create a dynamic Menu . This function is called from a ‘wp_nav_menu_items’ filter function. The below function creates a dynamic menu based on the buddypress groups the user is entitled to. The idea is to provide navigation to the groups directly via a Menu.

    function get_entitled_groups_menu_html()
    {
        $dataset  = getDS_entitled_groups();
        $html = "";
        foreach($dataset as $row)
        {
            $url = site_url()."/groups/".$row->slug;
            $html .= '<ul id="menu-item-381" align="right" class="bp-menu bp-groups-nav current_page_item current-menu-item menu-item menu-item-type-bp_nav menu-item-object-bp_loggedin_nav menu-item-381">';
            $html .= '<a href="'.$url.'">'.$row->name.'</a></ul>';
        }
        return $html;
    }

    The menu renders properly, however when clicked I get the warning. I know I can suppress the warning by turning WP_DEBUG off, but the fact that it does not throw an warning, when I navigate to the group page via going to groups page and then selecting the individual group, but only does when I navigate via this function makes me think there must be a better way.


    danbp
    Participant

    @danbp

    Hi,

    Assuming you want to add a menu item to WP main nav bar as single menu item
    Try this, from within bp-custom.php

    /* link to My Groups on WP main menu */
    function my_nav_menu_group_link( $menu ) {      
            if ( !is_user_logged_in() )
                    return $menu;
            else
                    $grouplink = '<li><a href="' . bp_loggedin_user_domain() . '/groups/">My Groups</a></li>';
                    $menu = $menu . $grouplink;
                    return $menu;
    }
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_group_link' );

    nickrobinson352
    Participant

    @nickrobinson352

    I tried that, still get the same warning 🙁

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar