Pergunta

I created a bp-custom.php and regrouped the menu items fine. But now i am trying to add a link to go to /site/members. It list all the members.

When i add it though it goes under the profile I am viewing. I am redirecting to a wordpress page if that helps. Or is there a better way to do this.

Ex :

http://website.com/log-in/members/username/members/

I want it to go just here

http://website.com/log-in/members/

I would love to learn how to just put a url and no slug but whatever works. I do not know why it keeps referencing that signed in /member/username. I have even tried parent url and that did not work. I might have been using parent url syntax wrong.

Here is the function

function mb_bp_profile_menu_posts() {
global $bp;
bp_core_new_nav_item(
array(
    'name' => 'Members',
    'slug' => 'members', 
    'position' => 60, 

     )
  );
}

I know that i can create .htaccess for this. But I don't want to do it.

May i know what is the clean way (alternate way) to do this?

I have tried what the user said in comment below and found in bp-members-template this function. I then added the part in bold to add the link but that did not work. I am just adding a google link for testing only.

 function bp_get_displayed_user_nav() {
global $bp;

foreach ( (array) $bp->bp_nav as $user_nav_item ) {
    if ( empty( $user_nav_item['show_for_displayed_user'] ) && !bp_is_my_profile() )
        continue;

    $selected = '';
    if ( bp_is_current_component( $user_nav_item['slug'] ) ) {
        $selected = ' class="current selected"';
    }

    if ( bp_loggedin_user_domain() ) {
        $link = str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $user_nav_item['link'] );
    } else {
        $link = trailingslashit( bp_displayed_user_domain() . $user_nav_item['link'] );
    }

    echo apply_filters_ref_array( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], array( '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ) );
**echo "<a href='http://www.google.com'>Google</a>"; }**

}

Foi útil?

Solução

The bp_core_new_nav_item function is used to add a link to the user's navigation which explains why you're seeing URLs like /members/username/members/ when clicking on the tab. I don't think bp_core_new_nav_item is the right approach here.

An alternative approach would be to replace the function in your theme template that outputs the navigation with your own custom menu.

See this article on the BP Template Hierarchy which shows you how you can set up your own templates:

http://codex.buddypress.org/themes/theme-compatibility-1-7/template-hierarchy/

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top