Remove 'Members' link from Buddypress menu

Hello support,

I am looking to remove the ‘Members’ link from buddypress menu, I entered the following code in x themes options, global css:

body:not(.logged-in) .sub-menu .menu-item-buddypress-navigation:nth-child(3) {
display: none }

It is still showing, is there another way, or code needs modification?

I look forward to your response, thank you

Hello There,

Thanks for writing in! Your code is valid and correct:

body:not(.logged-in) .sub-menu .menu-item-buddypress-navigation:nth-child(3) {
    display: none 
}

This will hide the members link in the BuddyPress submenu when a user is not logged in. If you are logged in, the members link will show up. You will need to log out first before you test the code. I would recommend using private browsing mode in testing your site.

If still not working, there might be some broken css in your that have affected this. Please provide us access to your site so that we can check it.

Thank you in advance.

Thank you for your prompt response, is there a way to hide the Members link all together? For those logged in and not logged in?

Hi there,

Please try:

body .sub-menu .menu-item-buddypress-navigation:nth-child(3) {
    display: none 
}

Here are some reference links related to the suggestions above:

Hope this helps.

Hello and thanks, I tried the code above, yet it is still showing.

If still not working, there might be some broken css in your that have affected this. Please provide us access to your site so that we can check it.

Info included via secure note. Thank you

Hello There,

It turns out that the css is not working because only two sub menu items is present in your site. I went ahead and resolved the issue by doing the following:

  • I installed a child theme. This allows you to make code changes that won’t be overwritten when an X update is released.
  • After the child theme is set up, I added the following code in your child theme’s functions.php file
// Miscellaneous
// =============================================================================

//
// Outputs a navigation item with quick links to BuddyPress-specific components
// such as the activity feed, current member profile, et cetera.
//

if ( ! function_exists( 'x_buddypress_navbar_menu' ) ) :
  function x_buddypress_navbar_menu( $items, $args ) {

    if ( X_BUDDYPRESS_IS_ACTIVE && x_get_option( 'x_buddypress_header_menu_enable' ) == '1' && did_action( 'x_classic_headers' ) ) {

      if ( bp_is_active( 'activity' ) ) {
        $logged_out_link = bp_get_activity_directory_permalink();
      } else if ( bp_is_active( 'groups' ) ) {
        $logged_out_link = bp_get_groups_directory_permalink();
      } else {
        $logged_out_link = bp_get_members_directory_permalink();
      }

      $top_level_link = ( is_user_logged_in() ) ? bp_loggedin_user_domain() : $logged_out_link;
      $submenu_items  = '';

      if ( bp_is_active( 'activity' ) ) {
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activity_directory_permalink() . '" class="cf"><i class="x-icon-thumbs-up" data-x-icon-s="&#xf164;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_activity_title' ) . '</span></a></li>';
      }

      if ( bp_is_active( 'groups' ) ) {
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_groups_directory_permalink() . '" class="cf"><i class="x-icon-sitemap" data-x-icon-s="&#xf0e8;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_groups_title' ) . '</span></a></li>';
      }

      if ( is_multisite() && bp_is_active( 'blogs' ) ) {
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_blogs_directory_permalink() . '" class="cf"><i class="x-icon-file" data-x-icon-s="&#xf15b;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_blogs_title' ) . '</span></a></li>';
      }

      //$submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_members_directory_permalink() . '" class="cf"><i class="x-icon-male" data-x-icon-s="&#xf183;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_members_title' ) . '</span></a></li>';

      if ( ! is_user_logged_in() ) {
        if ( bp_get_signup_allowed() ) {
          $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_signup_page() . '" class="cf"><i class="x-icon-pencil" data-x-icon-s="&#xf303;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_register_title' ) . '</span></a></li>';
          $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activation_page() . '" class="cf"><i class="x-icon-key" data-x-icon-s="&#xf084;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_activate_title' ) . '</span></a></li>';
        }
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . wp_login_url() . '" class="cf"><i class="x-icon-sign-in" data-x-icon-s="&#xf2f6;" aria-hidden="true"></i> <span>' . __( 'Log in', '__x__' ) . '</span></a></li>';
      } else {
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_loggedin_user_domain() . '" class="cf"><i class="x-icon-cog" data-x-icon-s="&#xf013;" aria-hidden="true"></i> <span>' . __( 'Profile', '__x__' ) . '</span></a></li>';
      }

      if ( $args->theme_location == 'primary' ) {
        $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">'
                  . '<a href="' . $top_level_link . '" class="x-btn-navbar-buddypress">'
                    . '<span><i class="x-icon-user" data-x-icon-s="&#xf007;" aria-hidden="true"></i><span class="x-hidden-desktop"> ' . __( 'Social', '__x__' ) . '</span></span>'
                  . '</a>'
                  . '<ul class="sub-menu">'
                    . $submenu_items
                  . '</ul>'
                . '</li>';
      }
    }

    return $items;

  }
  add_filter( 'wp_nav_menu_items', 'x_buddypress_navbar_menu', 9997, 2 );
endif;
// =============================================================================

The members link is removed from the code above so that it will no longer appear.

Please removed the given custom css because it is no longer needed.

Kindly check your site now.

1 Like

Thank you very much, it’s working great, the only thing I would like to do is add the following menu to it.

It’s only showing in the menu region of my widgets, but not in the x modified menu.

“Activate Your Account” option for not logged in users seems redundant, can you remove it, if it’s not too much of a hassle.

I don’t want to mess or add unnecessary code to a well written child theme you installed. Once more, thank you for your support.

Hello There,

Please be advised that the menu in your sidebar and the menu in the navbar were two separate independent menus.

The activate account sub menu item is already removed. If you want to add more things to it, please add your custom submenu item in the code I have added in your child theme.

Just keep in mind this:

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Thank you.

Great, I understand, thank you for your support throughout this thread.

You’re welcome!
We’re glad we were able to help you out.

1 Like

Hello support,

Originally on the X buddypress menu there are “Settings” and “Log out” that are present, but when I first started working on the layout it was just “Members” and “Profile” for logged in users (please refer to above image), with your help the “Members” link was removed via child theme installation. Could you provide me with the code (I don’t think it is custom) to add to the child theme so the “Settings” and “Log out” links can show in the menu? Thank you

Edit: Hope this does not bump the thread, the buddypress icon

When I am logged in it goes to my profile which is good. For someone that isn’t logged in, it goes to the Members page, which was the original link removed with your help. Is there a way to make this not do anything when clicked, or either just point it to account creation page.
I look forward to your response, thank you.
Thank you

Hello There,

You haven’t enabled other BuddyPress features. If you go to Settings > BuddyPress and enable other features then you will have the complete BuddyPress submenu items.

Please enable those features first so that you will find out which one you’ll add or removed.

Thanks.

Hello,

I am aware of all those features. All I am looking to do is:
• To have not logged in users when they click the X Buddypress icon to not go to the Members page (that is where it leads). I would like them to go to the account creation page or for it to not be a link at all but just an icon as is without linking to Members page (that would be ideal). Logged in users just go to their Buddypress profile when they click the icon (works great).

• To have Profile, Shop, Settings, Log Off in the drop down for logged in users.

Currently Profile is the only link showing for logged in users.

That is all I need to have the menu complete. Thank you for your support and I look forward to your response.

Hello There,

Thanks for updating in! I have updated the code and used this:

// Miscellaneous
// =============================================================================

//
// Outputs a navigation item with quick links to BuddyPress-specific components
// such as the activity feed, current member profile, et cetera.
//

if ( ! function_exists( 'x_buddypress_navbar_menu' ) ) :
  function x_buddypress_navbar_menu( $items, $args ) {

    if ( X_BUDDYPRESS_IS_ACTIVE && x_get_option( 'x_buddypress_header_menu_enable' ) == '1' && did_action( 'x_classic_headers' ) ) {

      if ( bp_is_active( 'activity' ) ) {
        $logged_out_link = bp_get_activity_directory_permalink();
      } else if ( bp_is_active( 'groups' ) ) {
        $logged_out_link = bp_get_groups_directory_permalink();
      } else {
        $logged_out_link = bp_get_members_directory_permalink();
      }

      //$top_level_link = ( is_user_logged_in() ) ? bp_loggedin_user_domain() : $logged_out_link;
      $top_level_link = ( is_user_logged_in() ) ? bp_loggedin_user_domain() : bp_get_signup_page();   
      $submenu_items  = '';

      if ( bp_is_active( 'activity' ) ) {
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activity_directory_permalink() . '" class="cf"><i class="x-icon-thumbs-up" data-x-icon-s="&#xf164;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_activity_title' ) . '</span></a></li>';
      }

      if ( bp_is_active( 'groups' ) ) {
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_groups_directory_permalink() . '" class="cf"><i class="x-icon-sitemap" data-x-icon-s="&#xf0e8;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_groups_title' ) . '</span></a></li>';
      }

      if ( is_multisite() && bp_is_active( 'blogs' ) ) {
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_blogs_directory_permalink() . '" class="cf"><i class="x-icon-file" data-x-icon-s="&#xf15b;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_blogs_title' ) . '</span></a></li>';
      }

      //$submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_members_directory_permalink() . '" class="cf"><i class="x-icon-male" data-x-icon-s="&#xf183;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_members_title' ) . '</span></a></li>';

      if ( ! is_user_logged_in() ) {
        if ( bp_get_signup_allowed() ) {
          $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_signup_page() . '" class="cf"><i class="x-icon-pencil" data-x-icon-s="&#xf303;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_register_title' ) . '</span></a></li>';
          //$submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activation_page() . '" class="cf"><i class="x-icon-key" data-x-icon-s="&#xf084;" aria-hidden="true"></i> <span>' . x_get_option( 'x_buddypress_activate_title' ) . '</span></a></li>';
        }
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . wp_login_url() . '" class="cf"><i class="x-icon-sign-in" data-x-icon-s="&#xf2f6;" aria-hidden="true"></i> <span>' . __( 'Log in', '__x__' ) . '</span></a></li>';
      } else {
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_loggedin_user_domain() . '" class="cf"><i class="x-icon-cog" data-x-icon-s="&#xf013;" aria-hidden="true"></i> <span>' . __( 'Profile', '__x__' ) . '</span></a></li>';
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . esc_url( home_url( '/shop/' ) ) . '" class="cf"><i class="x-icon-shopping-bag" data-x-icon-s="&#xf290;" aria-hidden="true"></i> <span>' . __( 'Shop', '__x__' ) . '</span></a></li>';
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_loggedin_user_domain() . 'settings/" class="cf"><i class="x-icon-cogs" data-x-icon-s="&#xf085;" aria-hidden="true"></i> <span>' . __( 'Settings', '__x__' ) . '</span></a></li>';
        $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . wp_logout_url( get_permalink() ) . '" class="cf"><i class="x-icon-sign-out-alt" data-x-icon-s="&#xf2f5;" aria-hidden="true"></i> <span>' . __( 'Log out', '__x__' ) . '</span></a></li>';
      }

      if ( $args->theme_location == 'primary' ) {
        $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">'
                  . '<a href="' . $top_level_link . '" class="x-btn-navbar-buddypress">'
                    . '<span><i class="x-icon-user" data-x-icon-s="&#xf007;" aria-hidden="true"></i><span class="x-hidden-desktop"> ' . __( 'Social', '__x__' ) . '</span></span>'
                  . '</a>'
                  . '<ul class="sub-menu">'
                    . $submenu_items
                  . '</ul>'
                . '</li>';
      }
    }

    return $items;

  }
  add_filter( 'wp_nav_menu_items', 'x_buddypress_navbar_menu', 9997, 2 );
endif;
// =============================================================================

Please be advised that we have given the code to get you started with your modifications to the buddypress menu item. Any addition from here on should solely be your responsibility.

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Thank you very much for your understanding.

1 Like

Understood and noted.
That is all I was wanting to do with the menu, you’ve been extremely helpful.
Thank you for your kind support.

You’re welcome. Please also note that we will not support issues that will arise from customizations either.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.